From 1514c7bac7f89a4b29e6abd192336e2ea4575352 Mon Sep 17 00:00:00 2001 From: Frederick Muriuki Muriithi Date: Thu, 27 Apr 2023 05:29:45 +0300 Subject: oauth2: Fix UI failure on authorisation errors Surround the UI elements with the check for any authorisation errors to avoid trying to access non-existent data (this leads to an exception). --- wqflask/wqflask/oauth2/resources.py | 2 +- wqflask/wqflask/templates/oauth2/view-resource.html | 12 ++++-------- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/wqflask/wqflask/oauth2/resources.py b/wqflask/wqflask/oauth2/resources.py index c01889c3..ed419076 100644 --- a/wqflask/wqflask/oauth2/resources.py +++ b/wqflask/wqflask/oauth2/resources.py @@ -116,7 +116,7 @@ def view_resource(resource_id: uuid.UUID): return oauth2_get(f"oauth2/resource/view/{resource_id}").either( lambda err: render_ui("oauth2/view-resource.html", - resource=None, error=process_error(err)), + resource=None, resource_error=process_error(err)), __resource_success__) @resources.route("/data/link", methods=["POST"]) diff --git a/wqflask/wqflask/templates/oauth2/view-resource.html b/wqflask/wqflask/templates/oauth2/view-resource.html index 43f3f5b9..873c3651 100644 --- a/wqflask/wqflask/templates/oauth2/view-resource.html +++ b/wqflask/wqflask/templates/oauth2/view-resource.html @@ -11,15 +11,11 @@
+ {%if resource_error is defined %} + {{display_error("Resource", resource_error)}} + {%else%}

Resource Details

- {%if error %} - - -   - {{error.error}} - {{error.error_description}} - {%else%} @@ -70,7 +66,6 @@
Resource: {{resource.resource_name}}
- {%endif%}
@@ -338,6 +333,7 @@ {%endif%}
+ {%endif%}
-- cgit v1.2.3