Spaces:
Runtime error
Runtime error
Canstralian
commited on
Commit
β’
b68999f
1
Parent(s):
162cc32
Create auth.py
Browse files
auth.py
ADDED
@@ -0,0 +1,22 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
import streamlit as st
|
2 |
+
|
3 |
+
def check_password():
|
4 |
+
"""Returns `True` if the user had the correct password."""
|
5 |
+
|
6 |
+
def password_entered():
|
7 |
+
"""Checks whether a password entered by the user is correct."""
|
8 |
+
if st.session_state["password"] == st.secrets["password"]:
|
9 |
+
st.session_state["password_correct"] = True
|
10 |
+
del st.session_state["password"] # Don't store the password
|
11 |
+
else:
|
12 |
+
st.session_state["password_correct"] = False
|
13 |
+
|
14 |
+
if "password_correct" not in st.session_state:
|
15 |
+
st.text_input("Password", type="password", on_change=password_entered, key="password")
|
16 |
+
return False
|
17 |
+
elif not st.session_state["password_correct"]:
|
18 |
+
st.text_input("Password", type="password", on_change=password_entered, key="password")
|
19 |
+
st.error("π Password incorrect")
|
20 |
+
return False
|
21 |
+
else:
|
22 |
+
return True
|