From 73ec268a916dcca601af5963402999b21d22fb41 Mon Sep 17 00:00:00 2001 From: TropiiDev Date: Tue, 29 Apr 2025 20:50:53 -0400 Subject: [PATCH] Fix bug with updating user passwords v0.0.9 --- api.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/api.py b/api.py index 9d85452..7619771 100644 --- a/api.py +++ b/api.py @@ -116,6 +116,14 @@ async def update_user(user: UserUpdate, session: SessionDep, current_user: User user_db = session.get(User, current_user.id) user_data = user.model_dump(exclude_unset=True) + # Check if the password is being updated + if 'password' in user_data: + # Generate a new salt + salt = random.randint(00000, 99999) + # Hash the new password with the new salt + user_data['password'] = hash_password(user_data['password'], salt) + user_data['salt'] = salt + user_db.sqlmodel_update(user_data) session.add(user_db) session.commit()