Spaces:
Sleeping
Sleeping
FauziIsyrinApridal commited on
Commit ·
b17b0dd
1
Parent(s): d99d7ed
revisi 17
Browse files- app/auth.py +39 -25
- requirements.txt +2 -1
app/auth.py
CHANGED
|
@@ -2,6 +2,7 @@ import os
|
|
| 2 |
import base64
|
| 3 |
import streamlit as st
|
| 4 |
from app.db import supabase
|
|
|
|
| 5 |
|
| 6 |
|
| 7 |
def auth_view():
|
|
@@ -28,31 +29,44 @@ def auth_view():
|
|
| 28 |
unsafe_allow_html=True
|
| 29 |
)
|
| 30 |
|
| 31 |
-
# --- FIX: Auto convert hash (#) to query (?) ---
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
|
| 43 |
-
|
| 44 |
-
|
| 45 |
-
|
| 46 |
-
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 56 |
|
| 57 |
# --- Recovery flow ---
|
| 58 |
if hasattr(st, "query_params"):
|
|
|
|
| 2 |
import base64
|
| 3 |
import streamlit as st
|
| 4 |
from app.db import supabase
|
| 5 |
+
from urllib.parse import parse_qsl
|
| 6 |
|
| 7 |
|
| 8 |
def auth_view():
|
|
|
|
| 29 |
unsafe_allow_html=True
|
| 30 |
)
|
| 31 |
|
| 32 |
+
# --- FIX: Auto convert hash (#) to query (?) using streamlit-url-fragment ---
|
| 33 |
+
try:
|
| 34 |
+
from streamlit_url_fragment import get_fragment
|
| 35 |
+
fragment = get_fragment()
|
| 36 |
+
|
| 37 |
+
if fragment and not st.session_state.get("hash_migrated"):
|
| 38 |
+
# Parse fragment parameters
|
| 39 |
+
params = dict(parse_qsl(fragment))
|
| 40 |
+
|
| 41 |
+
if params.get("type") == "recovery" and params.get("access_token"):
|
| 42 |
+
# Set query params so existing recovery flow works
|
| 43 |
+
if hasattr(st, "query_params"):
|
| 44 |
+
for key, value in params.items():
|
| 45 |
+
st.query_params[key] = value
|
| 46 |
+
else:
|
| 47 |
+
st.experimental_set_query_params(**params)
|
| 48 |
+
|
| 49 |
+
st.session_state["hash_migrated"] = True
|
| 50 |
+
st.rerun()
|
| 51 |
+
except ImportError:
|
| 52 |
+
# Fallback to JS if library not available
|
| 53 |
+
st.markdown(
|
| 54 |
+
"""
|
| 55 |
+
<script>
|
| 56 |
+
(function() {
|
| 57 |
+
const hash = window.location.hash;
|
| 58 |
+
if (hash && hash.length > 1 && !sessionStorage.getItem("hash_migrated")) {
|
| 59 |
+
const query = hash.substring(1);
|
| 60 |
+
const newUrl = window.location.pathname + "?" + query;
|
| 61 |
+
sessionStorage.setItem("hash_migrated", "true");
|
| 62 |
+
window.history.replaceState(null, "", newUrl);
|
| 63 |
+
window.location.reload();
|
| 64 |
+
}
|
| 65 |
+
})();
|
| 66 |
+
</script>
|
| 67 |
+
""",
|
| 68 |
+
unsafe_allow_html=True
|
| 69 |
+
)
|
| 70 |
|
| 71 |
# --- Recovery flow ---
|
| 72 |
if hasattr(st, "query_params"):
|
requirements.txt
CHANGED
|
@@ -118,4 +118,5 @@ streamlit_mic_recorder
|
|
| 118 |
gtts
|
| 119 |
edge-tts
|
| 120 |
playwright
|
| 121 |
-
dotenv
|
|
|
|
|
|
| 118 |
gtts
|
| 119 |
edge-tts
|
| 120 |
playwright
|
| 121 |
+
dotenv
|
| 122 |
+
streamlit-url-fragment
|