Login: add full-screen escape hatch for embedded (iframe) case
Browse filesWhen the app is opened from the HF Space page it runs in an iframe, where
st.login()'s redirect is blocked by Microsoft's frame-busting ("nothing
happens"). Add a host-agnostic link (href="/" target="_blank") to reopen the
app top-level where sign-in works.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
- auth_gate.py +17 -0
auth_gate.py
CHANGED
|
@@ -111,6 +111,13 @@ _LOGIN_CSS = """
|
|
| 111 |
text-align: center; line-height: 1.5;
|
| 112 |
}
|
| 113 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 114 |
@keyframes loginRise {
|
| 115 |
from { opacity: 0; transform: translateY(22px) scale(0.985); }
|
| 116 |
to { opacity: 1; transform: none; }
|
|
@@ -196,6 +203,16 @@ def require_login() -> None:
|
|
| 196 |
except Exception:
|
| 197 |
st.error("ไม่สามารถเริ่มการเข้าสู่ระบบได้ "
|
| 198 |
"กรุณาลองใหม่หรือติดต่อผู้ดูแลระบบ")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 199 |
else:
|
| 200 |
st.markdown(
|
| 201 |
"<div class='login-warn'>⚠ ระบบเข้าสู่ระบบยังไม่ถูกตั้งค่า<br>"
|
|
|
|
| 111 |
text-align: center; line-height: 1.5;
|
| 112 |
}
|
| 113 |
|
| 114 |
+
/* Escape hatch for the embedded (iframe) case */
|
| 115 |
+
.login-altlink {
|
| 116 |
+
margin: 0.5rem 1.7rem 0; text-align: center;
|
| 117 |
+
font-size: 0.72rem; color: #928981;
|
| 118 |
+
}
|
| 119 |
+
.login-altlink a { color: #F2B391 !important; text-decoration: underline; }
|
| 120 |
+
|
| 121 |
@keyframes loginRise {
|
| 122 |
from { opacity: 0; transform: translateY(22px) scale(0.985); }
|
| 123 |
to { opacity: 1; transform: none; }
|
|
|
|
| 203 |
except Exception:
|
| 204 |
st.error("ไม่สามารถเริ่มการเข้าสู่ระบบได้ "
|
| 205 |
"กรุณาลองใหม่หรือติดต่อผู้ดูแลระบบ")
|
| 206 |
+
# When opened embedded (the HF Space page runs the app in an iframe),
|
| 207 |
+
# st.login()'s redirect is blocked by Microsoft's frame-busting and
|
| 208 |
+
# "nothing happens". This escape hatch reopens the app top-level in a
|
| 209 |
+
# new tab (href="/" is host-agnostic) where sign-in works.
|
| 210 |
+
st.markdown(
|
| 211 |
+
"<div class='login-altlink'>ปุ่มไม่ทำงาน? "
|
| 212 |
+
"<a href='/' target='_blank' rel='noopener'>เปิดแบบเต็มหน้าจอ</a>"
|
| 213 |
+
" แล้วลองอีกครั้ง</div>",
|
| 214 |
+
unsafe_allow_html=True,
|
| 215 |
+
)
|
| 216 |
else:
|
| 217 |
st.markdown(
|
| 218 |
"<div class='login-warn'>⚠ ระบบเข้าสู่ระบบยังไม่ถูกตั้งค่า<br>"
|