Skip to content

Conversation

@KayvanShah1
Copy link

Summary

  • add email and display name fields to User model
  • enable users to view and update their own profile
  • cover profile retrieval and update with tests

Testing

  • python3 -m pytest

https://chatgpt.com/codex/tasks/task_e_68b10740b9508329b82d205529f92a63

Copy link

@chatgpt-codex-connector chatgpt-codex-connector bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Codex Review: Here are some suggestions.

Reply with @codex fix comments to fix any unresolved comments.

About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you open a pull request for review, mark a draft as ready, or comment "@codex review". If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex fix this CI failure" or "@codex address that feedback".

Comment on lines +61 to +72
data = update.model_dump(exclude_unset=True)
if "username" in data:
existing = await crud_user.get_user_by_username(db, data["username"])
if existing and existing.id != current_user.id:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail="Username already taken"
)
if "email" in data:
existing = await crud_user.get_user_by_email(db, data["email"])
if existing and existing.id != current_user.id:
raise HTTPException(
status_code=status.HTTP_400_BAD_REQUEST, detail="Email already taken"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

[P1] Skip email uniqueness check when clearing address

Both update_me and patch_me run a uniqueness check whenever the payload contains an email key, even when the value is null. Because get_user_by_email is then called with None, the query matches the first user that already has a NULL email (which is common because signups default to no email). The existing.id != current_user.id branch fires and returns 400 "Email already taken", making it impossible for a user to remove their email address while any other user also lacks one. The check should only run when a non-NULL email is supplied.

Useful? React with 👍 / 👎.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants