mirror of
https://github.com/RYDE-WORK/full-stack-fastapi-template.git
synced 2026-01-27 17:23:16 +08:00
🐛 Fix allowing a user to update the email to the same email they already have (#696)
This commit is contained in:
parent
55245e1ca4
commit
03eb49aa4d
@ -82,7 +82,7 @@ def update_user_me(
|
|||||||
|
|
||||||
if user_in.email:
|
if user_in.email:
|
||||||
existing_user = crud.get_user_by_email(session=session, email=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(
|
raise HTTPException(
|
||||||
status_code=409, detail="User with this email already exists"
|
status_code=409, detail="User with this email already exists"
|
||||||
)
|
)
|
||||||
@ -184,7 +184,7 @@ def update_user(
|
|||||||
)
|
)
|
||||||
if user_in.email:
|
if user_in.email:
|
||||||
existing_user = crud.get_user_by_email(session=session, email=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(
|
raise HTTPException(
|
||||||
status_code=409, detail="User with this email already exists"
|
status_code=409, detail="User with this email already exists"
|
||||||
)
|
)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user