MHamdan commited on
Commit
5d516d9
·
1 Parent(s): 2bd5cbf

Update login page with correct SPARKNET acronym and VISTA branding

Browse files
Files changed (1) hide show
  1. demo/auth.py +48 -26
demo/auth.py CHANGED
@@ -82,33 +82,49 @@ def check_password() -> bool:
82
  st.session_state["password_incorrect"] = True
83
  return
84
 
85
- # Get password(s) from secrets
86
- if "auth" in st.secrets:
87
- # Check single password
88
- if "password" in st.secrets["auth"]:
89
- if hmac.compare_digest(
90
- entered_password,
91
- st.secrets["auth"]["password"]
92
- ):
93
- st.session_state["authenticated"] = True
94
- st.session_state["username"] = "user"
95
- if "password" in st.session_state:
96
- del st.session_state["password"]
97
- return
98
-
99
- # Check multiple users
100
- if "passwords" in st.secrets["auth"]:
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  username = st.session_state.get("username_input", "")
102
-
103
  passwords = st.secrets["auth"]["passwords"]
104
- if username in passwords and hmac.compare_digest(
105
- entered_password, passwords[username]
106
- ):
107
- st.session_state["authenticated"] = True
108
- st.session_state["username"] = username
109
- if "password" in st.session_state:
110
- del st.session_state["password"]
111
- return
 
 
112
 
113
  st.session_state["authenticated"] = False
114
  st.session_state["password_incorrect"] = True
@@ -146,7 +162,13 @@ def check_password() -> bool:
146
 
147
  with col2:
148
  st.markdown('<div class="login-title">🔥 SPARKNET</div>', unsafe_allow_html=True)
149
- st.markdown('<div class="login-subtitle">Document Intelligence Platform</div>', unsafe_allow_html=True)
 
 
 
 
 
 
150
 
151
  st.markdown("---")
152
 
 
82
  st.session_state["password_incorrect"] = True
83
  return
84
 
85
+ # Get password(s) from secrets - try multiple locations
86
+ stored_password = None
87
+
88
+ # Try auth.password first
89
+ try:
90
+ if "auth" in st.secrets and "password" in st.secrets["auth"]:
91
+ stored_password = str(st.secrets["auth"]["password"]).strip()
92
+ except Exception:
93
+ pass
94
+
95
+ # Fallback: try root level password
96
+ if not stored_password:
97
+ try:
98
+ if "password" in st.secrets:
99
+ stored_password = str(st.secrets["password"]).strip()
100
+ except Exception:
101
+ pass
102
+
103
+ # Check single password
104
+ if stored_password:
105
+ # Use simple comparison (strip whitespace from both)
106
+ if entered_password.strip() == stored_password:
107
+ st.session_state["authenticated"] = True
108
+ st.session_state["username"] = "user"
109
+ if "password" in st.session_state:
110
+ del st.session_state["password"]
111
+ return
112
+
113
+ # Check multiple users (auth.passwords)
114
+ try:
115
+ if "auth" in st.secrets and "passwords" in st.secrets["auth"]:
116
  username = st.session_state.get("username_input", "")
 
117
  passwords = st.secrets["auth"]["passwords"]
118
+ if username in passwords:
119
+ stored_user_pass = str(passwords[username]).strip()
120
+ if entered_password.strip() == stored_user_pass:
121
+ st.session_state["authenticated"] = True
122
+ st.session_state["username"] = username
123
+ if "password" in st.session_state:
124
+ del st.session_state["password"]
125
+ return
126
+ except Exception:
127
+ pass
128
 
129
  st.session_state["authenticated"] = False
130
  st.session_state["password_incorrect"] = True
 
162
 
163
  with col2:
164
  st.markdown('<div class="login-title">🔥 SPARKNET</div>', unsafe_allow_html=True)
165
+ st.markdown('<div class="login-subtitle">Strategic Patent Acceleration & Research Kinetics NETwork</div>', unsafe_allow_html=True)
166
+ st.markdown("""
167
+ <div style="text-align: center; color: #8b949e; font-size: 0.85em; margin: 15px 0;">
168
+ AI-powered Technology Transfer Office Automation<br/>
169
+ <span style="color: #4ECDC4;">VISTA/Horizon EU Project</span>
170
+ </div>
171
+ """, unsafe_allow_html=True)
172
 
173
  st.markdown("---")
174