in atr/util.py [0:0]
def is_user_viewing_as_admin(uid: str | None) -> bool:
"""Check whether a user is currently viewing the site with active admin privileges."""
if not user.is_admin(uid):
return False
try:
app = asfquart.APP
if not hasattr(app, "app_id") or not isinstance(app.app_id, str):
_LOGGER.error("Cannot get valid app_id to read session for admin view check")
return True
cookie_id = app.app_id
session_dict = quart.session.get(cookie_id, {})
is_downgraded = session_dict.get("downgrade_admin_to_user", False)
return not is_downgraded
except Exception:
_LOGGER.exception(f"Error checking admin downgrade session status for {uid}")
return True