Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Better HTTP error codes #250

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def create_user(
user = crud.user.get_by_email(db, email=user_in.email)
if user:
raise HTTPException(
status_code=400,
status_code=409,
detail="The user with this username already exists in the system.",
)
user = crud.user.create(db, obj_in=user_in)
Expand Down Expand Up @@ -105,7 +105,7 @@ def create_user_open(
user = crud.user.get_by_email(db, email=email)
if user:
raise HTTPException(
status_code=400,
status_code=409,
detail="The user with this username already exists in the system",
)
user_in = schemas.UserCreate(password=password, email=email, full_name=full_name)
Expand All @@ -127,7 +127,7 @@ def read_user_by_id(
return user
if not crud.user.is_superuser(current_user):
raise HTTPException(
status_code=400, detail="The user doesn't have enough privileges"
status_code=401, detail="The user doesn't have enough privileges"

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be a 403

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@machadoug Can you change it?

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

agree, it should be a 403

)
return user

Expand Down