AnnasBlackHat commited on
Commit
6358d4a
·
1 Parent(s): 58f8884

using state

Browse files
Files changed (3) hide show
  1. app.py +5 -1
  2. pages/login.py +2 -1
  3. pages/manage_faqs.py +4 -1
app.py CHANGED
@@ -1,9 +1,13 @@
1
  import streamlit as st
2
 
 
 
 
3
  # st.set_page_config(page_title="FAQ and Chat App")
4
  st.title("FAQ and Chat App")
5
- st.write("Welcome to the FAQ and Chat App! Navigate using the sidebar.")
6
 
7
  st.page_link("pages/faq.py", label="FAQ")
8
  st.page_link("pages/chat.py", label="Chat")
9
 
 
 
1
  import streamlit as st
2
 
3
+ if 'auth_state' not in st.session_state:
4
+ st.session_state.auth_state = False
5
+
6
  # st.set_page_config(page_title="FAQ and Chat App")
7
  st.title("FAQ and Chat App")
8
+ st.write("Welcome to the FAQ and Chat App! You can read our FAQs or directly chat with our AI (experimental)")
9
 
10
  st.page_link("pages/faq.py", label="FAQ")
11
  st.page_link("pages/chat.py", label="Chat")
12
 
13
+
pages/login.py CHANGED
@@ -43,8 +43,9 @@ def login():
43
  password = st.text_input("Password", type="password")
44
  if st.button("Login"):
45
  if authenticate(username, password):
46
- st.success("Login successful!")
47
  cookie_manager.set('auth_state', 'authenticated')
 
48
  st.switch_page('pages/manage_faqs.py')
49
  else:
50
  st.error("Invalid username or password")
 
43
  password = st.text_input("Password", type="password")
44
  if st.button("Login"):
45
  if authenticate(username, password):
46
+ st.success("Login successful!")
47
  cookie_manager.set('auth_state', 'authenticated')
48
+ st.session_state.auth_state = True
49
  st.switch_page('pages/manage_faqs.py')
50
  else:
51
  st.error("Invalid username or password")
pages/manage_faqs.py CHANGED
@@ -8,7 +8,10 @@ cookie_manager = get_manager()
8
  auth_state = cookie_manager.get(cookie='auth_state')
9
  st.write(auth_state)
10
 
11
- if not auth_state == "authenticated":
 
 
 
12
  st.warning("You are not authorized to access this page. Please login.")
13
  st.stop()
14
 
 
8
  auth_state = cookie_manager.get(cookie='auth_state')
9
  st.write(auth_state)
10
 
11
+ if st.session_state.auth_state:
12
+ st.write('you are authenticated...')
13
+
14
+ if not auth_state == "authenticated" and st.session_state.auth_state == False:
15
  st.warning("You are not authorized to access this page. Please login.")
16
  st.stop()
17