wop commited on
Commit
d786a45
1 Parent(s): e3a1f9f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -8
app.py CHANGED
@@ -23,20 +23,25 @@ st.subheader("Chatbot", divider="rainbow", anchor=False)
23
  # LOGIN
24
  password = os.environ['PASSWORD']
25
 
 
 
 
26
  def login(password_input):
27
  if password_input == password:
28
  st.session_state.authenticated = True
29
- return # Exit the function after successful login
30
-
31
- st.error("Invalid username or password")
32
 
33
- login_container = st.container()
 
 
34
 
35
- # Password input and button inside the conditional block
36
  if "authenticated" not in st.session_state or not st.session_state.authenticated:
37
- with login_container:
38
- password_input = st.text_input("Password", type="password")
39
- st.button("authenticate", on_click=login, args=password_input)
40
 
41
  client = Groq(
42
  api_key=os.environ['GROQ_API_KEY'],
 
23
  # LOGIN
24
  password = os.environ['PASSWORD']
25
 
26
+ # Create a login form container
27
+ login_container = st.container()
28
+
29
  def login(password_input):
30
  if password_input == password:
31
  st.session_state.authenticated = True
32
+ login_container.empty() # Clear the login form container
33
+ else:
34
+ st.error("Invalid password")
35
 
36
+ with login_container:
37
+ password_input = st.text_input("Password", type="password")
38
+ st.button("authenticate", on_click=login(password_input))
39
 
40
+ # Only allow access to the app if the user is authenticated
41
  if "authenticated" not in st.session_state or not st.session_state.authenticated:
42
+ st.stop() # Stop the app from running if the user is not authenticated
43
+ else:
44
+ login_container.empty()
45
 
46
  client = Groq(
47
  api_key=os.environ['GROQ_API_KEY'],