diff options
Diffstat (limited to 'wqflask/wqflask/oauth2/ui.py')
-rw-r--r-- | wqflask/wqflask/oauth2/ui.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/wqflask/wqflask/oauth2/ui.py b/wqflask/wqflask/oauth2/ui.py index abf30f4e..315aae2b 100644 --- a/wqflask/wqflask/oauth2/ui.py +++ b/wqflask/wqflask/oauth2/ui.py @@ -2,13 +2,13 @@ from flask import session, render_template from .client import oauth2_get +from .checks import user_logged_in from .request_utils import process_error def render_ui(templatepath: str, **kwargs): """Handle repetitive UI rendering stuff.""" - logged_in = lambda: ("oauth2_token" in session and bool(session["oauth2_token"])) roles = kwargs.get("roles", tuple()) # Get roles if already provided - if logged_in() and not bool(roles): # If not, try fetching them + if user_logged_in() and not bool(roles): # If not, try fetching them roles_results = oauth2_get("oauth2/user/roles").either( lambda err: {"roles_error": process_error(err)}, lambda roles: {"roles": roles}) @@ -18,7 +18,6 @@ def render_ui(templatepath: str, **kwargs): privilege["privilege_id"] for role in roles for privilege in role["privileges"]) kwargs = { - **kwargs, "roles": roles, "user_privileges": user_privileges, - "logged_in": logged_in + **kwargs, "roles": roles, "user_privileges": user_privileges } return render_template(templatepath, **kwargs) |