Spaces:
Sleeping
Sleeping
login issue fixed
Browse files- app.py +48 -27
- config.yaml +2 -2
app.py
CHANGED
|
@@ -18,21 +18,38 @@ authenticator = stauth.Authenticate(
|
|
| 18 |
config["preauthorized"],
|
| 19 |
)
|
| 20 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 21 |
with st.sidebar:
|
| 22 |
if not st.session_state["authentication_status"]:
|
| 23 |
st.markdown(
|
| 24 |
"""
|
| 25 |
-
# Welcome to **Name of
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
|
| 27 |
"""
|
| 28 |
)
|
| 29 |
|
| 30 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
| 31 |
with st.expander("Login ๐", expanded=True):
|
| 32 |
authenticator.login("Login", "main")
|
| 33 |
|
| 34 |
if st.session_state["authentication_status"]:
|
| 35 |
-
authenticator.logout("Logout", "main", key="
|
| 36 |
st.write(f'Welcome *{st.session_state["name"]}*')
|
| 37 |
st.title(
|
| 38 |
"You logged in! You can choose a session in the bottom of the sidebar and view content."
|
|
@@ -42,7 +59,6 @@ with st.sidebar:
|
|
| 42 |
elif st.session_state["authentication_status"] is None:
|
| 43 |
st.warning("Please enter your username and password")
|
| 44 |
|
| 45 |
-
# Reset Password
|
| 46 |
with st.expander("Reset password ๐"):
|
| 47 |
if st.session_state["authentication_status"]:
|
| 48 |
try:
|
|
@@ -53,7 +69,6 @@ with st.sidebar:
|
|
| 53 |
except Exception as e:
|
| 54 |
st.error(e)
|
| 55 |
|
| 56 |
-
# Forgot Password
|
| 57 |
with st.expander("Forgot password ๐"):
|
| 58 |
try:
|
| 59 |
(
|
|
@@ -69,7 +84,6 @@ with st.sidebar:
|
|
| 69 |
except Exception as e:
|
| 70 |
st.error(e)
|
| 71 |
|
| 72 |
-
# Update User
|
| 73 |
with st.expander("Update user ๐"):
|
| 74 |
if st.session_state["authentication_status"]:
|
| 75 |
try:
|
|
@@ -80,8 +94,7 @@ with st.sidebar:
|
|
| 80 |
except Exception as e:
|
| 81 |
st.error(e)
|
| 82 |
|
| 83 |
-
|
| 84 |
-
with st.expander("Register user ๐", expanded=False):
|
| 85 |
try:
|
| 86 |
# payment_key = st.text_input("Enter Payment Key:")
|
| 87 |
if authenticator.register_user("Register user", preauthorization=False):
|
|
@@ -93,40 +106,48 @@ with st.sidebar:
|
|
| 93 |
with open("config.yaml", "w") as file:
|
| 94 |
yaml.dump(config, file, default_flow_style=False)
|
| 95 |
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
|
|
|
|
|
|
|
|
|
| 100 |
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
|
| 110 |
# Main
|
| 111 |
if st.session_state["authentication_status"]:
|
|
|
|
| 112 |
st.markdown(
|
| 113 |
"""
|
| 114 |
-
#
|
|
|
|
|
|
|
| 115 |
|
| 116 |
-
Welcome!
|
| 117 |
"""
|
| 118 |
)
|
| 119 |
|
| 120 |
-
# Add Main Content Here
|
| 121 |
-
# TODO
|
| 122 |
-
|
| 123 |
-
# Log out
|
| 124 |
with st.sidebar:
|
| 125 |
with st.expander("Login ๐", expanded=True):
|
| 126 |
authenticator.login("Login", "main")
|
| 127 |
|
| 128 |
if st.session_state["authentication_status"]:
|
| 129 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 130 |
st.write(f'Welcome *{st.session_state["name"]}*')
|
| 131 |
st.title(
|
| 132 |
"You logged in! You can choose a session in the bottom of the sidebar and view content."
|
|
|
|
| 18 |
config["preauthorized"],
|
| 19 |
)
|
| 20 |
|
| 21 |
+
|
| 22 |
+
# Credit: Time
|
| 23 |
+
def current_year():
|
| 24 |
+
now = datetime.now()
|
| 25 |
+
return now.year
|
| 26 |
+
|
| 27 |
+
|
| 28 |
with st.sidebar:
|
| 29 |
if not st.session_state["authentication_status"]:
|
| 30 |
st.markdown(
|
| 31 |
"""
|
| 32 |
+
# Welcome to **Name of App** ๐ถ๐ค
|
| 33 |
+
|
| 34 |
+
Introduction / Instruction Manual ...๐
|
| 35 |
+
|
| 36 |
+
### ๐ฑ๏ธPress "R" on your keyboardโจ๏ธ to rerun the app for faster loading ๐.
|
| 37 |
+
|
| 38 |
+
### ๐Sample login info - User: "jsmith" | Password: "abc"
|
| 39 |
|
| 40 |
"""
|
| 41 |
)
|
| 42 |
|
| 43 |
+
# Default video
|
| 44 |
+
st.write(
|
| 45 |
+
"๐ Guide to Data Science, Machine Learning, and Artificial Intelligence!"
|
| 46 |
+
)
|
| 47 |
+
|
| 48 |
with st.expander("Login ๐", expanded=True):
|
| 49 |
authenticator.login("Login", "main")
|
| 50 |
|
| 51 |
if st.session_state["authentication_status"]:
|
| 52 |
+
authenticator.logout("Logout", "main", key="unique_key_login")
|
| 53 |
st.write(f'Welcome *{st.session_state["name"]}*')
|
| 54 |
st.title(
|
| 55 |
"You logged in! You can choose a session in the bottom of the sidebar and view content."
|
|
|
|
| 59 |
elif st.session_state["authentication_status"] is None:
|
| 60 |
st.warning("Please enter your username and password")
|
| 61 |
|
|
|
|
| 62 |
with st.expander("Reset password ๐"):
|
| 63 |
if st.session_state["authentication_status"]:
|
| 64 |
try:
|
|
|
|
| 69 |
except Exception as e:
|
| 70 |
st.error(e)
|
| 71 |
|
|
|
|
| 72 |
with st.expander("Forgot password ๐"):
|
| 73 |
try:
|
| 74 |
(
|
|
|
|
| 84 |
except Exception as e:
|
| 85 |
st.error(e)
|
| 86 |
|
|
|
|
| 87 |
with st.expander("Update user ๐"):
|
| 88 |
if st.session_state["authentication_status"]:
|
| 89 |
try:
|
|
|
|
| 94 |
except Exception as e:
|
| 95 |
st.error(e)
|
| 96 |
|
| 97 |
+
with st.expander("Register user ๐"):
|
|
|
|
| 98 |
try:
|
| 99 |
# payment_key = st.text_input("Enter Payment Key:")
|
| 100 |
if authenticator.register_user("Register user", preauthorization=False):
|
|
|
|
| 106 |
with open("config.yaml", "w") as file:
|
| 107 |
yaml.dump(config, file, default_flow_style=False)
|
| 108 |
|
| 109 |
+
with st.expander("Donation๐ฒ"):
|
| 110 |
+
stripe_payment_link = "https://buy.stripe.com/cN2bLGa0faMp5u8fYZ"
|
| 111 |
+
st.markdown(
|
| 112 |
+
f"""
|
| 113 |
+
Want to support me? ๐ Done here using this [link]({stripe_payment_link}).
|
| 114 |
+
"""
|
| 115 |
+
)
|
| 116 |
|
| 117 |
+
# Credit:
|
| 118 |
+
current_year = current_year() # This will print the current year
|
| 119 |
+
st.markdown(
|
| 120 |
+
f"""
|
| 121 |
+
<h6 style='text-align: left;'>Copyright ยฉ 2010-{current_year} Present Yiqiao Yin</h6>
|
| 122 |
+
""",
|
| 123 |
+
unsafe_allow_html=True,
|
| 124 |
+
)
|
| 125 |
|
| 126 |
# Main
|
| 127 |
if st.session_state["authentication_status"]:
|
| 128 |
+
|
| 129 |
st.markdown(
|
| 130 |
"""
|
| 131 |
+
# Homepage ๐ถ๐ค
|
| 132 |
+
|
| 133 |
+
Content goes here.
|
| 134 |
|
|
|
|
| 135 |
"""
|
| 136 |
)
|
| 137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 138 |
with st.sidebar:
|
| 139 |
with st.expander("Login ๐", expanded=True):
|
| 140 |
authenticator.login("Login", "main")
|
| 141 |
|
| 142 |
if st.session_state["authentication_status"]:
|
| 143 |
+
try:
|
| 144 |
+
authenticator.logout("Logout", "main", key="unique_key")
|
| 145 |
+
except KeyError:
|
| 146 |
+
pass # ignore it
|
| 147 |
+
except Exception as err:
|
| 148 |
+
st.error(f"Unexpected exception {err}")
|
| 149 |
+
raise Exception(err) # but not this, let's crash the app
|
| 150 |
+
|
| 151 |
st.write(f'Welcome *{st.session_state["name"]}*')
|
| 152 |
st.title(
|
| 153 |
"You logged in! You can choose a session in the bottom of the sidebar and view content."
|
config.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
| 1 |
cookie:
|
| 2 |
expiry_days: 30
|
| 3 |
key: some_signature_key
|
| 4 |
-
name:
|
| 5 |
credentials:
|
| 6 |
usernames:
|
| 7 |
eagle0504:
|
|
@@ -18,4 +18,4 @@ credentials:
|
|
| 18 |
password: $2b$12$d6VtLvzfiMv7HBIF2kDhMeeyiyG/LQIUBhZA7e70zKsA/l5bVpQjK
|
| 19 |
preauthorized:
|
| 20 |
emails:
|
| 21 |
-
- melsby@gmail.com
|
|
|
|
| 1 |
cookie:
|
| 2 |
expiry_days: 30
|
| 3 |
key: some_signature_key
|
| 4 |
+
name: cookie_name
|
| 5 |
credentials:
|
| 6 |
usernames:
|
| 7 |
eagle0504:
|
|
|
|
| 18 |
password: $2b$12$d6VtLvzfiMv7HBIF2kDhMeeyiyG/LQIUBhZA7e70zKsA/l5bVpQjK
|
| 19 |
preauthorized:
|
| 20 |
emails:
|
| 21 |
+
- melsby@gmail.com
|