Skip to content

Commit

Permalink
do not write admin information on every page load
Browse files Browse the repository at this point in the history
  • Loading branch information
Kunsi committed Dec 23, 2024
1 parent ba17d20 commit d617991
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions frontend.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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"))
Expand Down

0 comments on commit d617991

Please sign in to comment.