Open shakkeel1330 opened 2 months ago
Hi @mkhorasani, Thank you for developing this great package! I just wanted to quickly check again if you have any suggestions with handling the issue I mentioned above.
Hi @mkhorasani, Thank you for developing this great package! I just wanted to quickly check again if you have any suggestions with handling the issue I mentioned above.
Hi @shakkeel1330, thank you for reaching out. Unfortunately, not yet, I'm currently inundated with a relatively large backlog of items to address. Will try my best to attend to this at some point in the near future too!
This works for me:
import streamlit as st
import streamlit_authenticator as stauth
import yaml
from yaml.loader import SafeLoader
from streamlit_authenticator.utilities import (Hasher, LoginError)
with open('./config.yaml') as file:
config = yaml.load(file, Loader=SafeLoader)
Hasher.hash_passwords(config['credentials'])
authenticator = stauth.Authenticate(config['credentials'],
config['cookie']['name'],
config['cookie']['key'],
config['cookie']['expiry_days'],
config['pre-authorized'])
def login():
pass
try:
authenticator.login()
except LoginError as e:
st.error(e)
if st.session_state['authentication_status']:
with st.sidebar:
authenticator.logout()
# Define pages
pages = [
st.Page("apps/page1.py", title="Page1"),
st.Page("apps/page2.py", title="Page2"),
]
# Use st.navigation
page = st.navigation(pages)
# Run the selected page
page.run()
elif st.session_state['authentication_status'] is False:
st.error('Username/password is incorrect')
elif st.session_state['authentication_status'] is None:
st.navigation([st.Page(login, title="Login")])
Description:
I am using the streamlit-authenticator package in my Streamlit app, which has two pages: the main page and a secondary page. The sidebar displays both page options when the app loads, even before the user is authenticated.
To provide a better user experience, I want the sidebar to be hidden on the login page and only become visible after the user has successfully logged in.
I've tried using CSS to hide the sidebar initially, but I am unsure of the best way to integrate this with the streamlit-authenticator package. I would appreciate guidance on how to accomplish this.
Sample Code:
Below is an abstracted version of my current setup:
Main Page:
Second page:
Directory structure:
├───src │ ├───pages │ │ └───second_page.py │ ├───services │ ├───utils │ ├───main.py ├──────
streamlit run main.py
Expected Outcome:
Any assistance on how to achieve this would be greatly appreciated!