File size: 701 Bytes
ed69556
 
 
 
437e992
ed69556
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
import hmac
import streamlit as st

def check_password():
    st.header("")
    def password_entered():
        if hmac.compare_digest(st.session_state["password"], st.secrets["adminpassword"]):
            st.session_state["password_correct"] = True
            del st.session_state["password"]  # Don't store the password.
        else:
            st.session_state["password_correct"] = False

    if st.session_state.get("password_correct", False):
        return True
    
    st.text_input(
        "Enter Password πŸš€", type="password", on_change=password_entered, key="password"
    )
    if "password_correct" in st.session_state:
        st.error("Password incorrect πŸ˜•")
    return False