Skip to content

Commit 03eb49a

Browse files
authored
🐛 Fix allowing a user to update the email to the same email they already have (#696)
1 parent 55245e1 commit 03eb49a

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

backend/app/api/routes/users.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ def update_user_me(
8282

8383
if user_in.email:
8484
existing_user = crud.get_user_by_email(session=session, email=user_in.email)
85-
if existing_user:
85+
if existing_user and existing_user.id != current_user.id:
8686
raise HTTPException(
8787
status_code=409, detail="User with this email already exists"
8888
)
@@ -184,7 +184,7 @@ def update_user(
184184
)
185185
if user_in.email:
186186
existing_user = crud.get_user_by_email(session=session, email=user_in.email)
187-
if existing_user:
187+
if existing_user and existing_user.id != user_id:
188188
raise HTTPException(
189189
status_code=409, detail="User with this email already exists"
190190
)

0 commit comments

Comments
 (0)