Chris8055 commited on
Commit
b71ddae
·
verified ·
1 Parent(s): 95bec67

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -9
app.py CHANGED
@@ -108,21 +108,24 @@ def login():
108
  else:
109
  st.warning("Please enter both name and email.")
110
 
 
111
  # Logout function
112
  def logout():
113
  st.session_state.logged_in = False
114
  st.session_state.user_name = None
115
  st.session_state.user_email = None
116
  st.success("Logged out successfully.")
117
- # Instead of rerunning the app immediately, just set a flag
118
- st.session_state.logout = True
119
 
120
  # Main App
121
- if st.session_state.logged_in:
122
- st.sidebar.title(f"Welcome, {st.session_state.user_name}!")
 
123
  if st.sidebar.button("Logout"):
124
- logout()
125
-
 
126
  st.sidebar.title("Task Filters")
127
  section = st.sidebar.radio("View Tasks", ["myDay", "thisWeek", "all"])
128
 
@@ -158,7 +161,5 @@ if st.session_state.logged_in:
158
  st.session_state.user_tasks.clear()
159
  st.success("All tasks deleted.")
160
  else:
161
- if 'logout' in st.session_state and st.session_state.logout:
162
- del st.session_state.logout # Remove the logout flag after using it
163
- st.experimental_rerun() # Rerun the app to show the login page
164
  login()
 
108
  else:
109
  st.warning("Please enter both name and email.")
110
 
111
+ # Logout function
112
  # Logout function
113
  def logout():
114
  st.session_state.logged_in = False
115
  st.session_state.user_name = None
116
  st.session_state.user_email = None
117
  st.success("Logged out successfully.")
118
+ # Reset the main view to show the login page
119
+
120
 
121
  # Main App
122
+ if st.session_state.get('logged_in', False):
123
+ st.sidebar.title(f"Welcome, {st.session_state.get('user_name', 'User')}!")
124
+
125
  if st.sidebar.button("Logout"):
126
+ logout() # Call logout function to clear session details
127
+
128
+ # Display the rest of the app (e.g., task manager)
129
  st.sidebar.title("Task Filters")
130
  section = st.sidebar.radio("View Tasks", ["myDay", "thisWeek", "all"])
131
 
 
161
  st.session_state.user_tasks.clear()
162
  st.success("All tasks deleted.")
163
  else:
164
+ # Render login form if the user is not logged in
 
 
165
  login()