mkhorasani / Streamlit-Authenticator

A secure authentication module to validate user credentials in a Streamlit application.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Auto login after registration

federico-cau-linkalab opened this issue · comments

Hi, great job with this component, it is really useful.

I was trying to do a login or register and I thought it would be useful to be able to have automatic login after a registration done with register_user(), maybe with a boolean parameter, e.g. login=True. This would avoid trying to find a way to do a page reset, and it would be more convenient for users who register not to have to log in right afterwards.

This is the code I am using

if not st.session_state['authentication_status']:
    tab1, tab2 = st.tabs(["Login", "Register"])
    with tab1:
        authenticator.login(location='main')
    with tab2:
        email_of_registered_user, username_of_registered_user, name_of_registered_user = authenticator.register_user(preauthorization=False)
        if email_of_registered_user:
            st.success('User registered successfully')
            with open('./config.yaml', 'w') as file:
                yaml.dump(config, file, default_flow_style=False)

Excellent idea, I will look into it for a future release.