🐛 Fix allowing a user to update the email to the same email they already have (#696)

This commit is contained in:
Alejandra
2024-03-12 19:24:35 +01:00
committed by GitHub
parent 55245e1ca4
commit 03eb49aa4d

View File

@@ -82,7 +82,7 @@ def update_user_me(
if user_in.email:
existing_user = crud.get_user_by_email(session=session, email=user_in.email)
if existing_user:
if existing_user and existing_user.id != current_user.id:
raise HTTPException(
status_code=409, detail="User with this email already exists"
)
@@ -184,7 +184,7 @@ def update_user(
)
if user_in.email:
existing_user = crud.get_user_by_email(session=session, email=user_in.email)
if existing_user:
if existing_user and existing_user.id != user_id:
raise HTTPException(
status_code=409, detail="User with this email already exists"
)