[FWA-3] fix cannot hash password
This commit is contained in:
@ -40,7 +40,8 @@ class RepositoryUsers:
|
||||
if not db_user:
|
||||
return None
|
||||
try:
|
||||
self.user.query.where(User.id == user_id).update(user.dict(exclude_unset=True))
|
||||
user.update_password()
|
||||
self.user.query.where(User.id == user_id).update(user.dict(exclude_unset=True, exclude_none=True))
|
||||
db.commit()
|
||||
except Exception:
|
||||
db.rollback()
|
||||
|
@ -3,6 +3,7 @@ from uuid import UUID
|
||||
from pydantic import ConfigDict
|
||||
from fastapi import Form
|
||||
|
||||
from backend.core.security.security import hash_password
|
||||
from backend.schemas.main_model import MainModel
|
||||
|
||||
class UserBase(MainModel):
|
||||
@ -21,6 +22,9 @@ class UserProfile(MainModel):
|
||||
is_lock: bool | None = None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
def update_password(self):
|
||||
self.password = (None if self.password is None else hash_password(self.password))
|
||||
|
||||
class UserSeeds(UserCreate):
|
||||
is_admin: bool
|
||||
is_lock: bool
|
||||
|
Reference in New Issue
Block a user