Skip to content

Commit

Permalink
add logout button and function #4
Browse files Browse the repository at this point in the history
  • Loading branch information
michivonah committed May 16, 2023
1 parent 16c4861 commit 6559252
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
7 changes: 7 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ def loginUser(email, password):
passwordHashed = hashlib.sha256(password.encode())
st.session_state['password'] = passwordHashed.hexdigest()
loginUser(email, st.session_state.password)
st.experimental_rerun()

else:
st.sidebar.info('Welcome back', icon="👋🏻")
logoutBtn = st.sidebar.button("Logout")

if logoutBtn:
usr.logout()
st.sidebar.info('Logged out')
st.experimental_rerun()
5 changes: 5 additions & 0 deletions usermanagement.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,11 @@ def checkLogin():
def showError():
st.write('You are not logged in. Please log in before accessing the settings.')

def logout():
st.session_state['loginSucceed'] = False
st.session_state['username'] = "SYSTEM"
st.session_state['userid'] = False

""" Example for use in page
import usermanagement as usr
Expand Down

0 comments on commit 6559252

Please sign in to comment.