Skip to content

Commit

Permalink
Status code when user exists
Browse files Browse the repository at this point in the history
  • Loading branch information
Mropat committed Oct 21, 2021
1 parent 8799d94 commit 42f7a01
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 3 deletions.
4 changes: 1 addition & 3 deletions statina/API/external/api/deps.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ def find_user(username: str) -> Optional[User]:
adapter: StatinaAdapter = get_nipt_adapter()
user: User = find.user(adapter=adapter, user_name=username)

if user and user.role != "inactive":
return user
return None
return user


def get_user_scopes(username: str) -> list:
Expand Down
3 changes: 3 additions & 0 deletions statina/API/v2/endpoints/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,9 @@ async def register_user(
password: str = Form(...),
adapter: StatinaAdapter = Depends(get_nipt_adapter),
):
user = find_user(username=username)
if user:
return JSONResponse(f"Username {username} already taken!", status_code=409)
if not secrets.compare_digest(password, password_repeated):
return JSONResponse(content="Password mismatch!", status_code=400)

Expand Down

0 comments on commit 42f7a01

Please sign in to comment.