Skip to content

Commit

Permalink
[frontend/profile] Fixing users without password couldn't define new …
Browse files Browse the repository at this point in the history
…password
  • Loading branch information
AlexandreDoneux committed Jan 10, 2024
1 parent 50a351a commit 4e2bf89
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions inginious/frontend/pages/preferences/profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,15 +59,18 @@ def save_profile(self, userdata, data):

if "password" in userdata:
user = self.user_manager.auth_user(self.user_manager.session_username(), data["oldpasswd"], False)
if user is None:
error = True
msg = _("Incorrect old password.")
return result, msg, error
else:
passwd_hash = UserManager.hash_password(data["passwd"])
result = self.database.users.find_one_and_update({"username": self.user_manager.session_username()},
{"$set": {"password": passwd_hash}},
return_document=ReturnDocument.AFTER)
else:
user = self.database.users.find_one({"username": userdata["username"]})

if user is None:
error = True
msg = _("Incorrect old password.")
return result, msg, error
else:
passwd_hash = UserManager.hash_password(data["passwd"])
result = self.database.users.find_one_and_update({"username": self.user_manager.session_username()},
{"$set": {"password": passwd_hash}},
return_document=ReturnDocument.AFTER)

# Check if updating language
if data["language"] != userdata["language"]:
Expand Down

0 comments on commit 4e2bf89

Please sign in to comment.