-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds passwords and fixes workbench bug
- Loading branch information
1 parent
9a0bb74
commit 7458b8f
Showing
6 changed files
with
100 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# common.py | ||
import streamlit as st | ||
|
||
def redirect(page_name): | ||
st.session_state.current_page = page_name | ||
st.experimental_rerun() | ||
|
||
def logged_in(): | ||
if 'logged_in' not in st.session_state: | ||
st.session_state.logged_in = False | ||
return st.session_state.logged_in | ||
|
||
def login(): | ||
st.session_state.logged_in = True | ||
st.experimental_rerun() | ||
|
||
def logout(): | ||
st.session_state.logged_in = False | ||
st.experimental_rerun() | ||
|
||
def manage_session_state(): | ||
# Check to make sure the user is logged in | ||
if 'admin_password' not in st.secrets: | ||
st.write("No admin password set. Please set the admin password in the secrets.") | ||
st.stop() | ||
else: | ||
admin_password = st.secrets["admin_password"]['password'] | ||
|
||
if logged_in() is False: | ||
# Log in the user by setting the session state variable | ||
# Get the password from the secrets and compare it to the user input | ||
# Make a login form | ||
password = st.text_input("Enter password", type="password") | ||
if st.button("Log in"): | ||
if password == admin_password: | ||
login() | ||
else: | ||
st.write("Incorrect password :", password, admin_password) | ||
st.stop() | ||
|
||
# Log out the user by setting the session state variable | ||
if st.button("Log out"): | ||
logout() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters