Spaces:
Running
Running
Phoenixak99
commited on
Update app.py
Browse files
app.py
CHANGED
@@ -156,7 +156,6 @@ st.title("Songlab AI")
|
|
156 |
# Ensure session state keys are initialized
|
157 |
if "jwt_token" not in st.session_state:
|
158 |
st.session_state["jwt_token"] = None
|
159 |
-
|
160 |
if "session_id" not in st.session_state:
|
161 |
st.session_state["session_id"] = None
|
162 |
|
@@ -164,6 +163,7 @@ if st.session_state["jwt_token"] is None:
|
|
164 |
st.header("Please log in to continue")
|
165 |
username = st.text_input("Username", key="username_input")
|
166 |
password = st.text_input("Password", type="password", key="password_input")
|
|
|
167 |
if st.button("Log in", key="login_button"):
|
168 |
login_url = "https://songlabai.com/wp-json/jwt-auth/v1/token"
|
169 |
data = {
|
@@ -178,15 +178,9 @@ if st.session_state["jwt_token"] is None:
|
|
178 |
st.success("Logged in successfully!")
|
179 |
st.rerun()
|
180 |
else:
|
181 |
-
|
182 |
-
|
183 |
-
|
184 |
-
'''with col2:
|
185 |
-
if st.button("Don't have an account?", key="register_button"):
|
186 |
-
js = "window.location.href = 'https://songlabai.com/register/';"
|
187 |
-
html = '<script>{}</script>'.format(js)
|
188 |
-
st.components.v1.html(html)
|
189 |
-
st.stop()'''
|
190 |
else:
|
191 |
# User is logged in, continue with the app
|
192 |
if st.button("Log out", key="logout_button"):
|
@@ -196,6 +190,7 @@ else:
|
|
196 |
st.rerun()
|
197 |
|
198 |
|
|
|
199 |
# Function to get the auth headers using the current jwt_token
|
200 |
def get_auth_headers():
|
201 |
jwt_token = st.session_state.get("jwt_token")
|
|
|
156 |
# Ensure session state keys are initialized
|
157 |
if "jwt_token" not in st.session_state:
|
158 |
st.session_state["jwt_token"] = None
|
|
|
159 |
if "session_id" not in st.session_state:
|
160 |
st.session_state["session_id"] = None
|
161 |
|
|
|
163 |
st.header("Please log in to continue")
|
164 |
username = st.text_input("Username", key="username_input")
|
165 |
password = st.text_input("Password", type="password", key="password_input")
|
166 |
+
|
167 |
if st.button("Log in", key="login_button"):
|
168 |
login_url = "https://songlabai.com/wp-json/jwt-auth/v1/token"
|
169 |
data = {
|
|
|
178 |
st.success("Logged in successfully!")
|
179 |
st.rerun()
|
180 |
else:
|
181 |
+
st.error("Invalid username or password")
|
182 |
+
st.stop()
|
183 |
+
st.stop()
|
|
|
|
|
|
|
|
|
|
|
|
|
184 |
else:
|
185 |
# User is logged in, continue with the app
|
186 |
if st.button("Log out", key="logout_button"):
|
|
|
190 |
st.rerun()
|
191 |
|
192 |
|
193 |
+
|
194 |
# Function to get the auth headers using the current jwt_token
|
195 |
def get_auth_headers():
|
196 |
jwt_token = st.session_state.get("jwt_token")
|