From 500f61b7ee9abc528be14d91dad959c59b030765 Mon Sep 17 00:00:00 2001 From: "Timothy J. Baek" Date: Fri, 29 Dec 2023 00:29:18 -0800 Subject: [PATCH] chore: update password refac --- backend/apps/web/models/auths.py | 16 ++++------------ backend/apps/web/routers/auths.py | 2 +- 2 files changed, 5 insertions(+), 13 deletions(-) diff --git a/backend/apps/web/models/auths.py b/backend/apps/web/models/auths.py index ce087316..0f96f096 100644 --- a/backend/apps/web/models/auths.py +++ b/backend/apps/web/models/auths.py @@ -114,19 +114,11 @@ class AuthsTable: except: return None - def update_user_password_by_id( - self, id: str, password: str, new_password: str - ) -> bool: + def update_user_password_by_id(self, id: str, new_password: str) -> bool: try: - auth = Auth.get(Auth.id == id, Auth.active == True) - if auth: - if verify_password(password, auth.password): - query = Auth.update(password=new_password).where(Auth.id == id) - result = query.execute() - print(result) - return True - else: - return False + query = Auth.update(password=new_password).where(Auth.id == id) + result = query.execute() + print(result) return True except: return False diff --git a/backend/apps/web/routers/auths.py b/backend/apps/web/routers/auths.py index bcbe00d5..9174865a 100644 --- a/backend/apps/web/routers/auths.py +++ b/backend/apps/web/routers/auths.py @@ -69,7 +69,7 @@ async def update_password(form_data: UpdatePasswordForm, cred=Depends(bearer_sch if user: hashed = get_password_hash(form_data.new_password) - return Auths.update_user_password_by_id(user.id, form_data.password, hashed) + return Auths.update_user_password_by_id(user.id, hashed) else: raise HTTPException(400, detail=ERROR_MESSAGES.INVALID_PASSWORD) else: