Skip to content

Commit

Permalink
check if your exams gets a 401 and then ask user to relogin
Browse files Browse the repository at this point in the history
  • Loading branch information
abhigyanghosh30 committed Jun 6, 2024
1 parent abf3f22 commit da4b7e0
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 6 deletions.
13 changes: 13 additions & 0 deletions webapp/shop/api/ua_contracts/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -458,6 +458,19 @@ def get_annotated_contract_items(
error_rules=["default"],
).json()

def get_cue_annotated_contract_items(
self, email: str = "", product_tags: List[str] = []
) -> List[dict]:
params = {"email": email}
params["productTags"] = ["cue"]

return self._request(
method="get",
path="/web/annotated-contract-items",
params=params,
error_rules=[],
).json()

def handle_error(self, error, error_rules=None):
if not error_rules:
return
Expand Down
17 changes: 11 additions & 6 deletions webapp/shop/cred/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -399,20 +399,25 @@ def cred_your_exams(ua_contracts_api, trueability_api, **kwargs):
agreement_notification = True

try:
exam_contracts = ua_contracts_api.get_annotated_contract_items(
product_tags=["cue"], email=email
exam_contracts = ua_contracts_api.get_cue_annotated_contract_items(
email=email
)
except UAContractsAPIErrorView as error:
except Exception as error:
print(error)
flask.current_app.extensions["sentry"].captureException(
extra={
"user_info": user_info(flask.session),
"request_url": error.request.url,
"request_headers": error.request.headers,
"request_url": flask.request.url,
"request_headers": flask.request.headers,
"response_headers": error.response.headers,
"response_body": error.response.json(),
}
)
exam_contracts = []
if error.response.status_code == 401:
return flask.redirect("/login?next=/credentials/your-exams")
else:
exam_contracts = []


exams_in_progress = []
exams_scheduled = []
Expand Down

0 comments on commit da4b7e0

Please sign in to comment.