forked from open-webui/open-webui
chore: update password refac
This commit is contained in:
parent
d8bb19fd8a
commit
500f61b7ee
2 changed files with 5 additions and 13 deletions
|
@ -114,20 +114,12 @@ class AuthsTable:
|
||||||
except:
|
except:
|
||||||
return None
|
return None
|
||||||
|
|
||||||
def update_user_password_by_id(
|
def update_user_password_by_id(self, id: str, new_password: str) -> bool:
|
||||||
self, id: str, password: str, new_password: str
|
|
||||||
) -> bool:
|
|
||||||
try:
|
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)
|
query = Auth.update(password=new_password).where(Auth.id == id)
|
||||||
result = query.execute()
|
result = query.execute()
|
||||||
print(result)
|
print(result)
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
return False
|
|
||||||
return True
|
|
||||||
except:
|
except:
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
|
@ -69,7 +69,7 @@ async def update_password(form_data: UpdatePasswordForm, cred=Depends(bearer_sch
|
||||||
|
|
||||||
if user:
|
if user:
|
||||||
hashed = get_password_hash(form_data.new_password)
|
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:
|
else:
|
||||||
raise HTTPException(400, detail=ERROR_MESSAGES.INVALID_PASSWORD)
|
raise HTTPException(400, detail=ERROR_MESSAGES.INVALID_PASSWORD)
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Reference in a new issue