Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure password is saved during user creation if provided #421

Merged
merged 1 commit into from
Jan 1, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading