Commit ad1cb5fc authored by Timothy J. Baek's avatar Timothy J. Baek
Browse files

fix: disable admin self user delete

parent b61bb779
......@@ -87,14 +87,20 @@ async def delete_user_by_id(user_id: str, cred=Depends(bearer_scheme)):
if user:
if user.role == "admin":
result = Users.delete_user_by_id(user_id)
if result:
return True
if user.id != user_id:
result = Users.delete_user_by_id(user_id)
if result:
return True
else:
raise HTTPException(
status_code=status.HTTP_500_INTERNAL_SERVER_ERROR,
detail=ERROR_MESSAGES.DELETE_USER_ERROR,
)
else:
raise HTTPException(
status_code=status.HTTP_403_FORBIDDEN,
detail=ERROR_MESSAGES.DELETE_USER_ERROR,
detail=ERROR_MESSAGES.ACTION_PROHIBITED,
)
else:
raise HTTPException(
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment