TangleSpace / hydralit

A library to create multi-page Streamlit applications with ease.
Apache License 2.0
202 stars 19 forks source link

Login and Logout through Hydralit! #38

Closed AravindRK99 closed 2 years ago

AravindRK99 commented 2 years ago

Hi there! I have recently discovered hydralit and I love the library so far. I am trying to built a login page that will redirect me to the page with multiple applications. In the hydralit example, I had noticed that there is a feature for Logout available which will redirect the user back to the login page.

My code for the Login page is as follows:

class LoginApp(HydraHeadApp): def run(self): c1, c2, c3 = st.columns(3) c1.write(" ") with c2: st.title("Login") if st.button('Guest Login', key='guestbtn'): st.success(f"✔️ Login success") with st.spinner("🤓 now redirecting to application...."): time.sleep(1) self.set_access(1, 'guest') self.do_redirect() c3.write(" ")

The page gets redirected to my home page but there is an additional tab next to the home page with the title "Login" and there's an error:

:sob: Error triggered from app: Logout Details: ‘Logout’

Am I missing something out here? Do I have to include additional code anywhere?

TangleSpace commented 2 years ago

i suggest you read the home page and study the example repo, as the entire solution works just fine when used correctly, the home and logout options are added automatically when running a secure app, so no need to specifically add them.

https://github.com/TangleSpace/hydralit-example