Streamlit-Authenticator, Part 1: Adding an authentication component to your app

Hey Mohammad,

I’m very new to streamlit/programming, so apologies in advance if what I’m asking is obvious.

I’m using the Streamlit Authenticator with a Deta database for a project. My question is regarding the hasher. I’ve found that when creating a new user in the database like this:

#start of code snipprt
email=['brackethashed@email.com']

username=['brackethashed']

firstname = ['hashed']

surname= ['hashed']

password=['password']

admin= ['True']

approved=['True']

hashed_password= stauth.Hasher(password).generate()

for (email, username, firstname, surname, admin, approved, hashed_password ) in zip(email, username, firstname, surname, admin, approved, hashed_password):

db.insert_user(email, username, firstname, surname, admin, approved, hashed_password)
#end of code snippet

is successful and the user can log in from the UI. The pasword is stored as a string like so: $2b$12$N9S/5MvUWul23adjozgQPeEg/D95QLxNfPuGusiJbVwXWtSAjhxuW.

However, when the brackets and zip are removed, the password is stored as an array

#start of code snippet
email='tostring@email.com'

username='tostring'

firstname = 'zipbracket'

surname= 'hashed'

password='password'

admin= 'True'

approved='True'

hashed_password= stauth.Hasher(password).generate()

db.insert_user(email, username, firstname, surname, admin, approved, hashed_password)
#end of code snippet.

the password gets stored like this:

"[
  "$2b$12$tt3dVgrDPUNAzKSuEOZ21OuJbZzQv0slQuB00lzicv8.hKig3LXA2",
  "$2b$12$Bt3My1MwTEU2hVHFkcZfn.rxW2TuoC6TKGiib4lc9nz44D4S23XBC", etc]

and the login module cannot decode the password.
The other fields are stored correctly as strings.

I have a sign up page that successfully inserts all the fields in the db except the hashed password. I guess I’m not exactly clear on how to ensure the hashed password is stored correctly without the use of an array and zip.

Apologies in advance for the long winded question. As I said, I’m very new to streamlit and deta. I’ve spent a few days trying to figure out the issue and thought I’d reach out and ask.

Thanks for taking the time to read this.

1 Like