mkhorasani / Streamlit-Authenticator

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

Suggested improvement: Remove spaces in input text in login form to prevent failed login during autocomplete #157

Open agomezh opened 1 month ago

agomezh commented 1 month ago

My browser autocompletes certain logins. It did with streamlit authenticator, but it (for some reason), added a space at the end. Therefore instead of 'my_username' it was 'my_username '. This prompted the authenticator to fail.

My suggestion is to add .strip() in the result of the username when logging in.

Line 197 of https://github.com/mkhorasani/Streamlit-Authenticator/blob/main/streamlit_authenticator/authenticate/__init__.py

From:

username = login_form.text_input('Username' if 'Username' not in fields else fields['Username']).lower()

To:

username = login_form.text_input('Username' if 'Username' not in fields else fields['Username']).lower().strip()

I would create a pull request, but I simply don't feel comfortable yet proposing such changes, so better to raise it here and discuss it if necessary.

Thank you for the component :).