Skip to content

Commit

Permalink
update password for users
Browse files Browse the repository at this point in the history
  • Loading branch information
nrjadkry committed Jul 10, 2024
1 parent 1e8b4ca commit 779910a
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
16 changes: 16 additions & 0 deletions src/backend/app/users/user_crud.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,22 @@ async def update_user_profile(
"certified_drone_operator": profile_update.certified_drone_operator,
},
)

# If password is provided, update the users table
if profile_update.password:
password_update_query = """
UPDATE users
SET password = :password
WHERE id = :user_id;
"""
await db.execute(
password_update_query,
{
"password": get_password_hash(profile_update.password),
"user_id": user_id,
},
)

return True
except Exception as e:
raise HTTPException(status_code=400, detail=str(e)) from e
1 change: 1 addition & 0 deletions src/backend/app/users/user_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,3 +88,4 @@ class ProfileUpdate(BaseModel):
experience_years: Optional[int] = None
certified_drone_operator: Optional[bool] = False
role: Optional[UserRole] = UserRole.DRONE_PILOT.name
password: Optional[str] = None

0 comments on commit 779910a

Please sign in to comment.