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 authored and legoktm committed Feb 12, 2024
1 parent fc1f027 commit af23ae9
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 af23ae9

Please sign in to comment.