Summary
Hey there, I work with a multipage app. I’m now trying to hide a page for specific users by using st.experimental_user.email
. On the main Page I’m able to not display the restricted page if a users does not have access. However, the restricted page keeps being displayed in the navbar. How can I also hide the page in the navbar?
Steps to reproduce
streamlit_app.py:
import streamlit as st
from restrictions import RESTRICTED_USERS
if st.experimental_user.email not in RESTRICTED_USERS:
st.markdown("- [First Page](/first_page)")
st.markdown("- [Second Page](/second_page)")
restrictions.py:
RESTRICTED_USERS = { 'user@sample.com'}
1_first_page.py:
import pandas as pd
import plotly.express as px
import plotly.graph_objects as go
import streamlit as st
from restrictions import RESTRICTED_USERS
# ----- Restriction ----
if st.experimental_user.email not in RESTRICTED_USERS:
pass
else:
st.warning('You do not have access to this page.', icon='🔑')
st.stop()
st.text('This should only be displayed if the user does not belong to the restricted users.')
File Structure:
streamlit_app.py
restrictions.py
└─── pages/
└─── 1_first_page.py (to be restricted)
└─── 2_second_page.py