From 11fe2a00ed1300c7545c4935e4b791a71be02e03 Mon Sep 17 00:00:00 2001 From: Dong-hyeon Shin <52447545+qu3vipon@users.noreply.github.com> Date: Tue, 12 Mar 2024 21:25:03 +0900 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=20Update=20error=20messages=20(#417)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Sebastián Ramírez --- backend/app/api/routes/login.py | 4 ++-- backend/app/api/routes/users.py | 6 +++--- backend/app/tests/api/routes/test_users.py | 8 ++------ 3 files changed, 7 insertions(+), 11 deletions(-) diff --git a/backend/app/api/routes/login.py b/backend/app/api/routes/login.py index e4f5a0b..ad78a2d 100644 --- a/backend/app/api/routes/login.py +++ b/backend/app/api/routes/login.py @@ -61,7 +61,7 @@ def recover_password(email: str, session: SessionDep) -> Message: if not user: raise HTTPException( status_code=404, - detail="The user with this username does not exist in the system.", + detail="The user with this email does not exist in the system.", ) password_reset_token = generate_password_reset_token(email=email) email_data = generate_reset_password_email( @@ -87,7 +87,7 @@ def reset_password(session: SessionDep, body: NewPassword) -> Message: if not user: raise HTTPException( status_code=404, - detail="The user with this username does not exist in the system.", + detail="The user with this email does not exist in the system.", ) elif not user.is_active: raise HTTPException(status_code=400, detail="Inactive user") diff --git a/backend/app/api/routes/users.py b/backend/app/api/routes/users.py index b726670..f4e98c2 100644 --- a/backend/app/api/routes/users.py +++ b/backend/app/api/routes/users.py @@ -56,7 +56,7 @@ def create_user(*, session: SessionDep, user_in: UserCreate) -> Any: if user: raise HTTPException( status_code=400, - detail="The user with this username already exists in the system.", + detail="The user with this email already exists in the system.", ) user = crud.create_user(session=session, user_create=user_in) @@ -130,7 +130,7 @@ def create_user_open(session: SessionDep, user_in: UserCreateOpen) -> Any: if user: raise HTTPException( status_code=400, - detail="The user with this username already exists in the system", + detail="The user with this email already exists in the system", ) user_create = UserCreate.from_orm(user_in) user = crud.create_user(session=session, user_create=user_create) @@ -174,7 +174,7 @@ def update_user( if db_user is None: raise HTTPException( status_code=404, - detail="The user with this username does not exist in the system", + detail="The user with this id does not exist in the system", ) return db_user diff --git a/backend/app/tests/api/routes/test_users.py b/backend/app/tests/api/routes/test_users.py index dcacead..2ab66bd 100644 --- a/backend/app/tests/api/routes/test_users.py +++ b/backend/app/tests/api/routes/test_users.py @@ -295,9 +295,7 @@ def test_create_user_open_already_exists_error( json=data, ) assert r.status_code == 400 - assert ( - r.json()["detail"] == "The user with this username already exists in the system" - ) + assert r.json()["detail"] == "The user with this email already exists in the system" def test_update_user( @@ -329,9 +327,7 @@ def test_update_user_not_exists( json=data, ) assert r.status_code == 404 - assert ( - r.json()["detail"] == "The user with this username does not exist in the system" - ) + assert r.json()["detail"] == "The user with this id does not exist in the system" def test_delete_user_super_user(