Skip to content

Commit

Permalink
Raise errors with expected format
Browse files Browse the repository at this point in the history
  • Loading branch information
bjester committed Nov 17, 2023
1 parent 0ce8716 commit 0ca87db
Showing 1 changed file with 6 additions and 5 deletions.
11 changes: 6 additions & 5 deletions kolibri/core/auth/utils/users.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,14 @@ def get_remote_users_info(baseurl, facility_id, username, password):
)
response.raise_for_status()
except (CommandError, HTTPError, ConnectionError) as e:
detail = []
if password == NOT_SPECIFIED or not password:
detail = [{"id": error_constants.MISSING_PASSWORD}]
raise AuthenticationFailed(detail)
raise AuthenticationFailed(
detail="Password is required", code=error_constants.MISSING_PASSWORD
)
else:
detail = [{"id": error_constants.AUTHENTICATION_FAILED, "message": e}]
raise AuthenticationFailed(detail)
raise AuthenticationFailed(
detail=str(e), code=error_constants.AUTHENTICATION_FAILED
)
auth_info = response.json()
if len(auth_info) > 1:
user_info = [u for u in response.json() if u["username"] == username][0]
Expand Down

0 comments on commit 0ca87db

Please sign in to comment.