about summary refs log tree commit diff
diff options
context:
space:
mode:
authorFrederick Muriuki Muriithi2023-04-27 05:29:45 +0300
committerFrederick Muriuki Muriithi2023-05-08 10:08:17 +0300
commit1514c7bac7f89a4b29e6abd192336e2ea4575352 (patch)
treeee8377322457b0293edfcae10210d243692d79a6
parent1608f1c092eb2011ecaf8485257648cc7971b213 (diff)
downloadgenenetwork2-1514c7bac7f89a4b29e6abd192336e2ea4575352.tar.gz
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).
-rw-r--r--wqflask/wqflask/oauth2/resources.py2
-rw-r--r--wqflask/wqflask/templates/oauth2/view-resource.html12
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 @@
 
   <div class="container-fluid">
 
+    {%if resource_error is defined %}
+    {{display_error("Resource", resource_error)}}
+    {%else%}
     <div class="row">
       <h3>Resource Details</h3>
-      {%if error %}
-      <span class="glyphicon glyphicon-exclamation-sign text-danger">
-      </span>
-      &nbsp;
-      <strong class="text-danger">{{error.error}}</strong>
-      {{error.error_description}}
-      {%else%}
       <table class="table">
 	<caption>Resource: {{resource.resource_name}}</caption>
 	<thead>
@@ -70,7 +66,6 @@
 	  </tr>
 	</tbody>
       </table>
-      {%endif%}
     </div>
 
     <div class="row">
@@ -338,6 +333,7 @@
       </form>
       {%endif%}
     </div>
+    {%endif%}
 
   </div>