[mod] don't use exception when not needed

This commit is contained in:
Laurent Peuch 2017-08-14 10:38:16 +02:00
parent d14bc31771
commit c14acc0fae

View file

@ -115,11 +115,8 @@ def user_create(auth, username, firstname, lastname, mail, password,
}) })
# Validate uniqueness of username in system users # Validate uniqueness of username in system users
try: all_existing_usernames = {x.pw_name for x in pwd.getpwall()}
pwd.getpwnam(username) if username in all_existing_usernames:
except KeyError:
pass
else:
raise MoulinetteError(errno.EEXIST, m18n.n('system_username_exists')) raise MoulinetteError(errno.EEXIST, m18n.n('system_username_exists'))
# Check that the mail domain exists # Check that the mail domain exists