Skip to content

Commit

Permalink
[frontend/user_manager] Small structure changes after PR comments
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandreDoneux committed Jan 10, 2024
1 parent 6aa534e commit 50a351a
Showing 1 changed file with 5 additions and 6 deletions.
11 changes: 5 additions & 6 deletions inginious/frontend/user_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -299,17 +299,16 @@ def auth_user(self, username, password, do_connect=True):
user = self._database.users.find_one(
{"username": username, "activate": {"$exists": False}})

def connect_user(username, user, do_connect):
return (user and self.connect_user(username, user["realname"], user["email"], user["language"],
user.get("tos_accepted", False)) if do_connect else user)

if user is None:
return None

method, db_hash = user["password"].split("-") if "-" in user["password"] else ("sha512", user["password"])
method, db_hash = user["password"].split("-", 1) if "-" in user["password"] else ("sha512", user["password"])

if self.verify_hash(db_hash, password, method):
return connect_user(username, user, do_connect)
if do_connect:
self.connect_user(username, user["realname"], user["email"], user["language"],
user.get("tos_accepted", False))
return user

def verify_hash(cls, db_hash, password, method="sha512"):
"""
Expand Down

0 comments on commit 50a351a

Please sign in to comment.