refactor(auth): Move check for verificated mail address to user class

This commit is contained in:
Georg Krause 2022-11-06 20:14:23 +01:00 committed by Georg Krause
commit 127a10f3d9
6 changed files with 21 additions and 24 deletions

View file

@ -27,7 +27,7 @@ def authenticate(username, password):
except (User.DoesNotExist, binascii.Error):
raise exceptions.AuthenticationFailed("Wrong username or password.")
if common_authentication.should_verify_email(user):
if user.should_verify_email():
raise exceptions.AuthenticationFailed("You need to verify your e-mail address.")
return (user, None)
@ -46,7 +46,7 @@ def authenticate_salt(username, salt, token):
if expected != token:
raise exceptions.AuthenticationFailed("Wrong username or password.")
if common_authentication.should_verify_email(user):
if user.should_verify_email():
raise exceptions.AuthenticationFailed("You need to verify your e-mail address.")
return (user, None)