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

This commit is contained in:
kaiyou
2017-11-05 18:12:50 +01:00
parent baff8dd043
commit 45902ae012

View File

@@ -37,20 +37,21 @@ 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)
for token in user.tokens: if user:
if (token.check_password(password) and for token in user.tokens:
(not token.ip or token.ip == ip)): if (token.check_password(password) and
return { (not token.ip or token.ip == ip)):
"Auth-Status": "OK", return {
"Auth-Server": server, "Auth-Status": "OK",
"Auth-Port": port "Auth-Server": server,
} "Auth-Port": port
if user and user.check_password(password): }
return { if user.check_password(password):
"Auth-Status": "OK", return {
"Auth-Server": server, "Auth-Status": "OK",
"Auth-Port": port "Auth-Server": server,
} "Auth-Port": port
}
else: else:
status, code = get_status(protocol, "authentication") status, code = get_status(protocol, "authentication")
return { return {