eagle0504 commited on
Commit
cb1a4c5
ยท
1 Parent(s): eb52a5c

login issue fixed

Browse files
Files changed (2) hide show
  1. app.py +48 -27
  2. 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 the App**
 
 
 
 
 
 
26
 
27
  """
28
  )
29
 
30
- # Login
 
 
 
 
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="unique_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
- # Register User
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
- # Credit: Time
97
- def current_year():
98
- now = datetime.now()
99
- return now.year
 
 
 
100
 
101
- # Credit:
102
- current_year = current_year() # This will print the current year
103
- st.markdown(
104
- f"""
105
- <h6 style='text-align: left;'>Copyright ยฉ 2010-{current_year} Present Yiqiao Yin</h6>
106
- """,
107
- unsafe_allow_html=True,
108
- )
109
 
110
  # Main
111
  if st.session_state["authentication_status"]:
 
112
  st.markdown(
113
  """
114
- # Content of the App
 
 
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
- authenticator.logout("Logout", "main", key="unique_key")
 
 
 
 
 
 
 
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: some_cookie_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