Files
co_app/app/tools/check_permission.py
2025-12-10 07:43:10 +01:00

27 lines
819 B
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import streamlit as st
from auth_runtime import require_login
from auth import get_sidebar, get_fullname_for_user, get_role_for_user
def check(df, page_name):
if "df_sidebar" not in st.session_state:
# authenticator = require_login()
username = st.session_state.get("username")
role_text = get_role_for_user(username)
fullname = get_fullname_for_user(username)
df = get_sidebar(role_text, username)
st.session_state["role_text"] = role_text
st.session_state["fullname"] = fullname
st.session_state["df_sidebar"] = df
if df is None or df.empty:
return False # oder True je nach gewünschtem Verhalten
allowed = not df[
(df["dash_type"] == "page") &
(df["page_file"] == page_name)
].empty
return True