Don't do more work than necessary

master
Florent Daigniere 4 years ago
parent 464e46b02b
commit 58b2cdc428

@ -49,11 +49,14 @@ def handle_authentication(headers):
user = models.User.query.get(user_email) user = models.User.query.get(user_email)
status = False status = False
if user: if user:
for token in user.tokens: # All tokens are 32 characters hex lowercase
if (token.check_password(password) and if len(password) == 32:
(not token.ip or token.ip == ip)): for token in user.tokens:
status = True if (token.check_password(password) and
if user.check_password(password): (not token.ip or token.ip == ip)):
status = True
break
if not status and user.check_password(password):
status = True status = True
if status: if status:
if protocol == "imap" and not user.enable_imap: if protocol == "imap" and not user.enable_imap:

Loading…
Cancel
Save