Skip to content

Commit

Permalink
refactor(authenticate): let _send_json_request() catch JSONDecodeErrors
Browse files Browse the repository at this point in the history
  • Loading branch information
cfm committed Jan 23, 2024
1 parent 1188421 commit 984f19d
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions client/securedrop_client/sdk/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -245,12 +245,9 @@ def authenticate(self, totp: Optional[str] = None) -> bool:
path_query = "api/v1/token"
body = json.dumps(user_data)

try:
response = self._send_json_request(
method, path_query, body=body, timeout=self.default_request_timeout
)
except json.decoder.JSONDecodeError:
raise BaseError("Error in parsing JSON")
response = self._send_json_request(
method, path_query, body=body, timeout=self.default_request_timeout
)

if "expiration" not in response.data:
raise AuthError("Authentication error")
Expand Down

0 comments on commit 984f19d

Please sign in to comment.