Fix a bug when trying to authenticate with a non existing user

master
kaiyou 7 years ago
parent baff8dd043
commit 45902ae012

@ -37,6 +37,7 @@ def handle_authentication(headers):
password = urllib.parse.unquote(headers["Auth-Pass"]) password = urllib.parse.unquote(headers["Auth-Pass"])
ip = urllib.parse.unquote(headers["Client-Ip"]) ip = urllib.parse.unquote(headers["Client-Ip"])
user = models.User.query.get(user_email) user = models.User.query.get(user_email)
if user:
for token in user.tokens: for token in user.tokens:
if (token.check_password(password) and if (token.check_password(password) and
(not token.ip or token.ip == ip)): (not token.ip or token.ip == ip)):
@ -45,7 +46,7 @@ def handle_authentication(headers):
"Auth-Server": server, "Auth-Server": server,
"Auth-Port": port "Auth-Port": port
} }
if user and user.check_password(password): if user.check_password(password):
return { return {
"Auth-Status": "OK", "Auth-Status": "OK",
"Auth-Server": server, "Auth-Server": server,

Loading…
Cancel
Save