From 352cded1cfed94cc1e3c906b1bee2a397190ec67 Mon Sep 17 00:00:00 2001 From: Younes Henni Date: Thu, 22 Jan 2026 12:42:05 +0000 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20Simplify=20reset=20passwor?= =?UTF-8?q?d=20logic=20by=20removing=20duplicate=20code=20(#1440)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/routes/login.py | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/backend/app/api/routes/login.py b/backend/app/api/routes/login.py index 980c66f..87b04d1 100644 --- a/backend/app/api/routes/login.py +++ b/backend/app/api/routes/login.py @@ -9,8 +9,7 @@ from app import crud from app.api.deps import CurrentUser, SessionDep, get_current_active_superuser from app.core import security from app.core.config import settings -from app.core.security import get_password_hash -from app.models import Message, NewPassword, Token, UserPublic +from app.models import Message, NewPassword, Token, UserPublic, UserUpdate from app.utils import ( generate_password_reset_token, generate_reset_password_email, @@ -91,10 +90,12 @@ def reset_password(session: SessionDep, body: NewPassword) -> Message: ) elif not user.is_active: raise HTTPException(status_code=400, detail="Inactive user") - hashed_password = get_password_hash(password=body.new_password) - user.hashed_password = hashed_password - session.add(user) - session.commit() + user_in_update = UserUpdate(password=body.new_password) + crud.update_user( + session=session, + db_user=user, + user_in=user_in_update, + ) return Message(message="Password updated successfully")