mkhorasani / Streamlit-Authenticator

A secure authentication module to validate user credentials in a Streamlit application.
Apache License 2.0
1.38k stars 229 forks source link

Add clear on submit option to authenticate.py reset_password() #85

Closed ascidian-ai closed 10 months ago

ascidian-ai commented 10 months ago

Hi @mkhorasani,

Thanks for building and sharing a great streamlit package!

I want to be able to reset the fields after my user resets their pwd so I don't have to force refresh of the reset pwd page.

Adding an additional parameter to the reset_password() in authenticate.py would allow clearing of fields on submission and I believe a simple solution to this issue.

def reset_password(self, username: str, form_name: str, location: str='main', clear_on_submit=False) -> bool:
...
        if location == 'main':
            reset_password_form = st.form('Reset password', clear_on_submit=clear_on_submit)
        elif location == 'sidebar':
            reset_password_form = st.sidebar.form('Reset password', clear_on_submit=clear_on_submit)
...
mkhorasani commented 10 months ago

Hey @ascidian-ai, thank you for the idea. Sure thing, will push this in the next release!