mkhorasani / Streamlit-Authenticator

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

update user details -> new name or email not being set in Cookie #196

Closed brdemorin closed 3 months ago

brdemorin commented 3 months ago

Mohammad, I'm trying to put in the whole kitchen sink of everything you provided for us!

After running "authenticator.update_user_details", I am using the below to access name / email to see which changed to update my firestore db:

email_from_update_user_details = credentials['usernames'][st.session_state.username]['email']
name_from_update_user_details = credentials['usernames'][st.session_state.username]['name']

While the session state is updated with the new values, the cookie retains the old values

Is there a way I can access and manage the cookies myself?? If so, then no fix needed

Moreover, it would be nice to have flexibility to remove fields like "email" as I don't want that to change, thx!!

mkhorasani commented 3 months ago

Hi @brdemorin, thank you for reaching out. The update_user_details widget is indeed updating the cookie when a user modifies a user detail, however, I think the issue is that the session_state is not being updated in time for the method that sets the new cookie. I will look into this and if need be will add a short pause after the method to rectify the issue. I will also look into removing fields on-demand like you requested. Please stay tuned for a future release to address these issues!

brdemorin commented 3 months ago

You are a rock star. A few coffees coming your way

BTW, it IS setting session state and updating the credentials variable just fine. It is not persisting beyond the session, thus not in cookie.

Is there a method for getting/setting cookies I can use?? That would be EXTREMELY helpful so I could solve this myself without waiting on a fix

mkhorasani commented 3 months ago

You are a rock star. A few coffees coming your way

BTW, it IS setting session state and updating the credentials variable just fine. It is not persisting beyond the session, thus not in cookie.

Is there a method for getting/setting cookies I can use?? That would be EXTREMELY helpful so I could solve this myself without waiting on a fix

That's very kind of you! We appear to be having problems with setting cookies with newer versions of Streamlit and also on some cloud servers in particular. Streamlit is rolling out its own native implementation of cookies, and I will gradually roll it out in the hopes of solving these problems once and for all! In the meantime please feel free to take a look at the CookieModel class where I manage cookies. The cookie model is implemented using another third-party Streamlit component called Extra-Streamlit-Components you might want to also take a look at that. Cheers!

brdemorin commented 3 months ago

Thx for the detailed response! Do you know of any cloud providers where the cookie component works across browsers? At least chrome, safari, edge

I have tried: streamlit community cloud google cloud run (via docker container) heroku render

None work except render which will work for chrome only

mkhorasani commented 3 months ago

Thx for the detailed response! Do you know of any cloud providers where the cookie component works across browsers? At least chrome, safari, edge

I have tried: streamlit community cloud google cloud run (via docker container) heroku render

None work except render which will work for chrome only

For me, Streamlit Cloud has always worked. I've also tried Azure and it seems to work fine.

brdemorin commented 3 months ago

Hmm. Last question -> what version of streamlit are you running? I’m 1.35.0

mkhorasani commented 3 months ago

Hmm. Last question -> what version of streamlit are you running? I’m 1.35.0

1.25.0, the next release however, will be for the latest version of Streamlit.

brdemorin commented 3 months ago

Ok. Maybe I need to roll back to 1.25 to see if a difference

next release however, will be for the latest version of Streamlit.

Didn't follow. You mean you plan to make the jump to 1.37.0 soon?

mkhorasani commented 3 months ago

Ok. Maybe I need to roll back to 1.25 to see if a difference

next release however, will be for the latest version of Streamlit.

Didn't follow. You mean you plan to make the jump to 1.37.0 soon?

Yeap, v0.3.4 of Streamlit-Authenticator will be made compatible (hopefully) with Streamlit v1.37.0.

brdemorin commented 3 months ago

Got it! What do you think your timeline is if you didn't get pestered all the time by the likes of me on here ;)?

mkhorasani commented 3 months ago

Got it! What do you think your timeline is if you didn't get pestered all the time by the likes of me on here ;)?

You're not pestering me, you're helping me fix pesky issues which is highly appreciated! I hope to release v0.3.4 in the next 2-3 weeks.