From 50a351a7220659e3a3f84c910a531db9bf09edf2 Mon Sep 17 00:00:00 2001 From: AlexandreDoneux <94830560+AlexandreDoneux@users.noreply.github.com> Date: Wed, 10 Jan 2024 16:37:11 +0100 Subject: [PATCH] [frontend/user_manager] Small structure changes after PR comments --- inginious/frontend/user_manager.py | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/inginious/frontend/user_manager.py b/inginious/frontend/user_manager.py index 868ddd8cc..5537b1dfd 100644 --- a/inginious/frontend/user_manager.py +++ b/inginious/frontend/user_manager.py @@ -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"): """