aboutsummaryrefslogtreecommitdiff
path: root/gn2/wqflask/oauth2/ui.py
diff options
context:
space:
mode:
Diffstat (limited to 'gn2/wqflask/oauth2/ui.py')
-rw-r--r--gn2/wqflask/oauth2/ui.py11
1 files changed, 6 insertions, 5 deletions
diff --git a/gn2/wqflask/oauth2/ui.py b/gn2/wqflask/oauth2/ui.py
index 90d65e0b..04095420 100644
--- a/gn2/wqflask/oauth2/ui.py
+++ b/gn2/wqflask/oauth2/ui.py
@@ -1,16 +1,17 @@
"""UI utilities"""
-from flask import session, render_template
+from flask import render_template
from .client import oauth2_get
-from .client import user_logged_in
-from .request_utils import process_error
def render_ui(templatepath: str, **kwargs):
"""Handle repetitive UI rendering stuff."""
roles = kwargs.get("roles", tuple()) # Get roles
+ if not roles:
+ roles = oauth2_get("auth/system/roles").either(
+ lambda _err: roles, lambda auth_roles: auth_roles)
user_privileges = tuple(
- privilege for role in roles for privilege in role["privileges"])
+ privilege["privilege_id"] for role in roles for privilege in role["privileges"])
kwargs = {
- **kwargs, "roles": roles, "user_privileges": user_privileges
+ **kwargs, "roles": roles, "user_privileges": user_privileges,
}
return render_template(templatepath, **kwargs)