From 03eb49aa4d433fb9cb462a191c796396e3fa6b5e Mon Sep 17 00:00:00 2001 From: Alejandra <90076947+alejsdev@users.noreply.github.com> Date: Tue, 12 Mar 2024 19:24:35 +0100 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20Fix=20allowing=20a=20user=20to?= =?UTF-8?q?=20update=20the=20email=20to=20the=20same=20email=20they=20alre?= =?UTF-8?q?ady=20have=20(#696)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- backend/app/api/routes/users.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/backend/app/api/routes/users.py b/backend/app/api/routes/users.py index ab4642a..1cd5d15 100644 --- a/backend/app/api/routes/users.py +++ b/backend/app/api/routes/users.py @@ -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" )