diff --git a/frontend.py b/frontend.py index a50f623..1b67958 100644 --- a/frontend.py +++ b/frontend.py @@ -42,6 +42,7 @@ is_within_timeframe, login_required, ) +from util.redis import REDIS from util.sso import SSO_CONFIG app = Flask( @@ -131,6 +132,8 @@ 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 diff --git a/syncer.py b/syncer.py index 000a6f8..ae1b5fb 100644 --- a/syncer.py +++ b/syncer.py @@ -5,7 +5,8 @@ from conf import CONFIG from ib_hosted import ib from notifier import Notifier -from util import Asset, State, get_all_live_assets, get_assets, user_is_admin +from util import Asset, State, get_all_live_assets, get_assets +from util.redis import REDIS FADE_TIME = 0.5 SLIDE_TIME = 10 @@ -46,7 +47,8 @@ def asset_to_tiles(asset: Asset): "config": {"fade_time": FADE_TIME}, } ) - if not user_is_admin(asset.user): + + if REDIS.get(f"admin:{asset.userid}") == "1": tiles.append( { "type": "flat", diff --git a/util/__init__.py b/util/__init__.py index f6c1689..6e719ac 100644 --- a/util/__init__.py +++ b/util/__init__.py @@ -138,7 +138,9 @@ def get_assets(cached=False): def get_user_assets(): - return [a for a in get_assets() if a.userid == g.userid and a.state != State.DELETED] + return [ + a for a in get_assets() if a.userid == g.userid and a.state != State.DELETED + ] def get_assets_awaiting_moderation(): diff --git a/util/sso/c3voc.py b/util/sso/c3voc.py index 5fa3968..daea7ef 100644 --- a/util/sso/c3voc.py +++ b/util/sso/c3voc.py @@ -5,6 +5,7 @@ LOG = getLogger("SSO-C3VOC") + def get_c3voc_userid(userinfo_json): return "c3voc:{}".format(userinfo_json["preferred_username"])