mkhorasani / Streamlit-Authenticator

A secure authentication module to manage user access in a Streamlit application.
Other
1.66k stars 258 forks source link

yaml dump works wrong #227

Closed sheriffff closed 1 month ago

sheriffff commented 1 month ago

If user peter is using the app, and you yaml dump credentials like step 13, you persist the data logged_in: true and the user is prevented from entering again the app if single login is active

you kinda need this

def add_user_to_config_yaml(user_info: dict) -> None:
    with open(CONFIG_PATH, 'r') as f:
        temp_config = yaml.load(f, Loader=SafeLoader)

    temp_config['credentials']['usernames'].update(user_info)

    with open(CONFIG_PATH, 'w') as f:
        yaml.dump(temp_config, f, default_flow_style=False)
mkhorasani commented 1 month ago

Hi @sheriffff. I'm not sure if I understood the query correctly, but this behavior is intended, i.e. if the user is already logged in and single_session=True they should NOT be allowed to log in on another device. However if they log out, the logged_in field will be set to False and saved to the config file.