|
import streamlit as st |
|
|
|
def check_password(): |
|
"""Returns `True` if the user had the correct password.""" |
|
|
|
def password_entered(): |
|
"""Checks whether a password entered by the user is correct.""" |
|
if st.session_state["password"] in st.secrets["passwords"]: |
|
st.session_state['user'] = st.session_state["password"] |
|
st.session_state["password_correct"] = True |
|
else: |
|
st.session_state["password_correct"] = False |
|
|
|
if "password_correct" not in st.session_state: |
|
|
|
st.text_input( |
|
"Password", type="password", on_change=password_entered, key="password" |
|
) |
|
return False |
|
elif not st.session_state["password_correct"]: |
|
|
|
st.text_input( |
|
"Password", type="password", on_change=password_entered, key="password" |
|
) |
|
st.error("π Password incorrect") |
|
return False |
|
else: |
|
|
|
return True |