Skip to content

Commit

Permalink
fix:Ensure password is saved during user creation if provided (#421)
Browse files Browse the repository at this point in the history
- Updated logic to handle cases where a password is provided during profile creation.

Improved user creation flow to avoid incomplete records.

Added checks to hash and save the password if it's present.
  • Loading branch information
Pradip-p authored Jan 1, 2025
1 parent a1b021e commit b04cc56
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/backend/app/users/user_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,18 @@ async def create(db: Connection, user_id: int, profile_create: UserProfileCreate
async with db.cursor() as cur:
await cur.execute(sql, model_data)

if profile_create.password:
password_update_query = """
UPDATE users
SET password = %(password)s
WHERE id = %(user_id)s;
"""
hashed_password = user_logic.get_password_hash(profile_create.password)
await cur.execute(
password_update_query,
{"password": hashed_password, "user_id": user_id},
)

for file_type, url_key in field_mapping.items():
if results.get(file_type):
model_data[url_key] = results[file_type].get("presigned_url")
Expand Down

0 comments on commit b04cc56

Please sign in to comment.