From d617991f5282bc098792bad8e0712b86e3b5f536 Mon Sep 17 00:00:00 2001 From: Franziska Kunsmann Date: Mon, 23 Dec 2024 21:30:40 +0100 Subject: [PATCH] do not write admin information on every page load --- frontend.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/frontend.py b/frontend.py index 1b67958..0a54d09 100644 --- a/frontend.py +++ b/frontend.py @@ -132,8 +132,6 @@ def before_request(): user_is_admin = SSO_CONFIG[provider]["functions"]["is_admin"](userinfo) user_without_limits = SSO_CONFIG[provider]["functions"]["no_limit"](userinfo) - REDIS.set(f"admin:{userid}", "1" if user_is_admin else "0") - if not (user_is_admin or user_without_limits or is_within_timeframe()): return @@ -245,6 +243,10 @@ def oauth2_callback(provider): session["oauth2_provider"] = provider session["oauth2_userinfo"] = userinfo_json + + user_is_admin = SSO_CONFIG[provider]["functions"]["is_admin"](userinfo) + REDIS.set(f"admin:{userid}", "1" if user_is_admin else "0") + if "redirect_after_login" in session: return redirect(session["redirect_after_login"]) return redirect(url_for("dashboard"))