Skip to content

feat: validate existing email and set 201 status on user creation#2239

Open
Sergy988 wants to merge 1 commit intofastapi:masterfrom
Sergy988:improve-user-creation
Open

feat: validate existing email and set 201 status on user creation#2239
Sergy988 wants to merge 1 commit intofastapi:masterfrom
Sergy988:improve-user-creation

Conversation

@Sergy988
Copy link

This PR introduces three small but important improvements to the user creation endpoint:

  • Email Validation: Added a check using crud.get_user_by_email to verify if the user already exists. If it does, it now properly raises an HTTPException with a 400 status code, preventing database errors or silent failures.

  • Correct HTTP Status: Added status_code=status.HTTP_201_CREATED to the router decorator to correctly reflect the creation of a new resource.

  • Keyword-only Arguments: Added the * symbol in the function signature to enforce keyword-only arguments, adhering to FastAPI and Python best practices.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants