-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathauth.py
More file actions
35 lines (27 loc) · 902 Bytes
/
auth.py
File metadata and controls
35 lines (27 loc) · 902 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
import streamlit as st
import os
from dotenv import load_dotenv
def check_password():
"""
Simple, robust login check using native Streamlit UI.
"""
load_dotenv()
SECRET_PASSWORD = os.getenv("APP_PASSWORD")
# Initialize Session State
if "authenticated" not in st.session_state:
st.session_state.authenticated = False
# If already logged in, return True
if st.session_state.authenticated:
return True
# --- NATIVE LOGIN UI ---
st.title("🔐 Login Required")
with st.form("login_form"):
password = st.text_input("Enter Password", type="password")
submit = st.form_submit_button("Login")
if submit:
if password == SECRET_PASSWORD:
st.session_state.authenticated = True
st.rerun()
else:
st.error("❌ Incorrect Password")
return False