Skip to content

Commit 230639f

Browse files
committed
bugfix: using logout after experimental_login with google errors out.
Was unable to logout without manually clearing cookies. I think what happens is the __main__ runs through the logout once, clearing the username from the credentials, and then runs through it again, but the key no longer exists, so it errors out. Fix simply adds an if check to make sure the `st.session_state['username']` exists
1 parent dcd1857 commit 230639f

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

streamlit_authenticator/models/authentication_model.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -418,7 +418,8 @@ def logout(self, callback: Optional[Callable]=None):
418418
callback: callable, optional
419419
Callback function that will be invoked on button press.
420420
"""
421-
self.credentials['usernames'][st.session_state['username']]['logged_in'] = False
421+
if st.session_state.get('username') in self.credentials['usernames']:
422+
self.credentials['usernames'][st.session_state['username']]['logged_in'] = False
422423
st.session_state['logout'] = True
423424
st.session_state['name'] = None
424425
st.session_state['username'] = None

0 commit comments

Comments
 (0)