You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Hello! I noticed the same while I was studying this course.
To solve this problem, I decided to create a similar solution at the very beginning of this function:
query = db.query(models.User).filter(models.User.email == user.email)
if query.first() != None:
raise HTTPException(status_code=status.HTTP_409_CONFLICT,
detail=f"Email {user.email} has already been used to create an user")
After this, password is hashed, user is validated, info is added, committed and refreshed and finally new_user is returned
Server Error on creating users for duplicated emails, the api returns:
DETAIL: Key (email)=([email protected]) already exists.
To solve this, it should be included this code into create_user function in routers\user.py
The text was updated successfully, but these errors were encountered: