Closed leo-fengchao closed 7 months ago
Dear @leo-fengchao, if you are using Streamlit-Authenticator with multi-page apps, you will have to recreate the authenticator object on each and every page and invoke the login method as shown below:
authenticator = stauth.Authenticate(
config['credentials'],
config['cookie']['name'],
config['cookie']['key'],
config['cookie']['expiry_days'],
config['pre-authorized']
)
authenticator.login()
This is to ensure that when a user hard refreshes the page and the session state variables related to re-authentication are lost, the authenticator object is there to re-initialize them from the cookie saved on the browser.
On default, the authentication_status stores in session_state which makes the login status sync across multi pages.
However, in my case, I don't want the authentication_status sync across multi pages.
For now, I added some code to achieve this need. It will check current loggin username is existed in config yaml file of current page. If not, it will set authentication_status to None and logout to True. Manually log the current user out.
Hope there would be a native support for this.