DavMelchi commited on
Commit
aa56dd5
·
1 Parent(s): c2acacc
Files changed (1) hide show
  1. app.py +26 -20
app.py CHANGED
@@ -1,25 +1,42 @@
 
 
1
  import streamlit as st
2
 
3
 
4
  # Authentication function
5
  def check_password():
6
  """Returns `True` if the user had the correct password."""
7
- # st.write(st.secrets)
 
 
 
 
 
 
8
 
9
  def password_entered():
10
  """Checks whether a password entered by the user is correct."""
 
 
 
 
 
 
 
 
11
  if (
12
- st.session_state["username"] == st.secrets["username"]
13
- and st.session_state["password"] == st.secrets["password"]
 
 
14
  ):
15
  st.session_state["password_correct"] = True
16
- print(st.session_state["password_correct"])
17
- print(st.session_state["username"])
18
- print(st.session_state["password"])
19
- del st.session_state["password"] # don't store password
20
- del st.session_state["username"] # don't store username
21
  else:
22
  st.session_state["password_correct"] = False
 
 
23
 
24
  # Create a visually appealing login form
25
  if (
@@ -81,18 +98,7 @@ def check_password():
81
  "password_correct" in st.session_state
82
  and not st.session_state["password_correct"]
83
  ):
84
- st.error(
85
- "😕 User not known or password incorrect"
86
- # + "the username is "
87
- # + st.secrets["username"]
88
- # + " and the password is "
89
- # + st.secrets["password"]
90
- # + st.session_state["username"]
91
- # + st.session_state["password"]
92
- )
93
- print(st.session_state["username"])
94
- print(st.session_state["password"])
95
- print(st.session_state["password_correct"])
96
 
97
  # Login form with improved input fields
98
  st.text_input("Username", key="username", placeholder="Enter your username")
 
1
+ import os
2
+
3
  import streamlit as st
4
 
5
 
6
  # Authentication function
7
  def check_password():
8
  """Returns `True` if the user had the correct password."""
9
+ # Debug: Print out all available secrets and environment variables
10
+ # st.write("Available Secrets:")
11
+ # st.write(dict(st.secrets))
12
+
13
+ # Debug: Check environment variables
14
+ # st.write("Environment Variables:")
15
+ # st.write(dict(os.environ))
16
 
17
  def password_entered():
18
  """Checks whether a password entered by the user is correct."""
19
+ # Debug: Print out detailed login information
20
+ st.write("Login Attempt Details:")
21
+ st.write(f"Input Username: {st.session_state.get('username', 'N/A')}")
22
+ st.write(f"Input Password: {st.session_state.get('password', 'N/A')}")
23
+ st.write(f"Stored Username: {st.secrets.get('username', 'N/A')}")
24
+ st.write(f"Stored Password: {st.secrets.get('password', 'N/A')}")
25
+
26
+ # Flexible comparison to handle potential type or whitespace issues
27
  if (
28
+ str(st.session_state.get("username", "")).strip()
29
+ == str(st.secrets.get("username", "")).strip()
30
+ and str(st.session_state.get("password", "")).strip()
31
+ == str(st.secrets.get("password", "")).strip()
32
  ):
33
  st.session_state["password_correct"] = True
34
+ print("Login Successful: Credentials Matched")
35
+ st.success("Login Successful!")
 
 
 
36
  else:
37
  st.session_state["password_correct"] = False
38
+ print("Login Failed: Credentials Do Not Match")
39
+ st.error("Login Failed: Check your credentials")
40
 
41
  # Create a visually appealing login form
42
  if (
 
98
  "password_correct" in st.session_state
99
  and not st.session_state["password_correct"]
100
  ):
101
+ st.error("😕 User not known or password incorrect")
 
 
 
 
 
 
 
 
 
 
 
102
 
103
  # Login form with improved input fields
104
  st.text_input("Username", key="username", placeholder="Enter your username")