How to display error message when new password does not match with repeat password using streamlit authenticator widget?
Steps to reproduce
Code snippet:
if authenticator.reset_password(username, 'Reset password'):
st.success('Password modified successfully')
The above code resets the password if we enter new password and repeat password as same, but the widget just dissapears without displaying any error if the two passwords do not match. How can I fix this?
Expected behavior:
I expect the program to show an error message as- “New password and Repeat password does not match, please try again”
Actual behavior:
The widget entirely dissapears without letting the users know that the password could not be reset. This does not reset the password.
Reference
Check out this blog for code on authenticator widget.
I’m not an expert on that component, but it looks like this logic is implemented in line 277 of this file.
if reset_password_form.form_submit_button('Reset'):
if self._check_credentials(inplace=False):
if len(new_password) > 0:
if new_password == new_password_repeat:
if self.password != new_password:
self._update_password(self.username, new_password)
return True
else:
raise ResetError('New and current passwords are the same')
else:
raise ResetError('Passwords do not match')
else:
raise ResetError('No new password provided')
else:
raise CredentialsError
Hello Caroline, I’ve another question about password resets.
This is my code for the widget:
Where will the new password be sent to? Is it via email? Cos i can’t seem to find it! thank you so much!
username_of_forgotten_password, email_of_forgotten_password, new_random_password = authenticator.forgot_password('Reset password here')
if username_of_forgotten_password:
st.success('New password sent securely')
Oh I figured it out! It returns the parameter of new_random_password and its up to me on how I want to securely transfer it to the user or just have it simply written in the next line.
Thanks for stopping by! We use cookies to help us understand how you interact with our website.
By clicking “Accept all”, you consent to our use of cookies. For more information, please see our privacy policy.
Cookie settings
Strictly necessary cookies
These cookies are necessary for the website to function and cannot be switched off. They are usually only set in response to actions made by you which amount to a request for services, such as setting your privacy preferences, logging in or filling in forms.
Performance cookies
These cookies allow us to count visits and traffic sources so we can measure and improve the performance of our site. They help us understand how visitors move around the site and which pages are most frequently visited.
Functional cookies
These cookies are used to record your choices and settings, maintain your preferences over time and recognize you when you return to our website. These cookies help us to personalize our content for you and remember your preferences.
Targeting cookies
These cookies may be deployed to our site by our advertising partners to build a profile of your interest and provide you with content that is relevant to you, including showing you relevant ads on other websites.