Spaces:
Sleeping
Sleeping
Sync app from GitHub Actions (feature/project-state-security-privacy-review)
Browse files- src/ui/login_page.py +7 -8
- src/ui/theme.py +93 -0
- tests/unit/test_login_page.py +1 -0
src/ui/login_page.py
CHANGED
|
@@ -8,16 +8,18 @@ from src.auth.auth_service import AuthService
|
|
| 8 |
|
| 9 |
|
| 10 |
def oauth_action_button_html(*, signed_in: bool = False) -> str:
|
| 11 |
-
"""Render the visible HF OAuth action
|
| 12 |
if signed_in:
|
| 13 |
href = "/logout"
|
| 14 |
label = "Sign out"
|
|
|
|
| 15 |
onclick = (
|
| 16 |
"sessionStorage.removeItem('birdnet_hf_login_intent');"
|
| 17 |
)
|
| 18 |
else:
|
| 19 |
href = "/login/huggingface?birdnet_login_intent=1"
|
| 20 |
label = "Sign in with Hugging Face"
|
|
|
|
| 21 |
onclick = (
|
| 22 |
"const q=new URLSearchParams(window.location.search);"
|
| 23 |
"q.set('birdnet_login_intent','1');"
|
|
@@ -29,13 +31,10 @@ def oauth_action_button_html(*, signed_in: bool = False) -> str:
|
|
| 29 |
return (
|
| 30 |
"<div class='bn-oauth-login-html' "
|
| 31 |
"style='box-sizing:border-box;width:100%;max-width:var(--bn-login-width,680px);margin:0 auto;'>"
|
| 32 |
-
f"<a href='{href}' target='_self' onclick=\"{onclick}\" "
|
| 33 |
-
"
|
| 34 |
-
"
|
| 35 |
-
"
|
| 36 |
-
"font-weight:780;text-decoration:none;white-space:nowrap;overflow:hidden;"
|
| 37 |
-
"text-overflow:ellipsis;'>"
|
| 38 |
-
f"{label}"
|
| 39 |
"</a>"
|
| 40 |
"</div>"
|
| 41 |
)
|
|
|
|
| 8 |
|
| 9 |
|
| 10 |
def oauth_action_button_html(*, signed_in: bool = False) -> str:
|
| 11 |
+
"""Render the visible HF OAuth action while keeping login intent explicit."""
|
| 12 |
if signed_in:
|
| 13 |
href = "/logout"
|
| 14 |
label = "Sign out"
|
| 15 |
+
state_class = "bn-hf-oauth-link-signed-in"
|
| 16 |
onclick = (
|
| 17 |
"sessionStorage.removeItem('birdnet_hf_login_intent');"
|
| 18 |
)
|
| 19 |
else:
|
| 20 |
href = "/login/huggingface?birdnet_login_intent=1"
|
| 21 |
label = "Sign in with Hugging Face"
|
| 22 |
+
state_class = "bn-hf-oauth-link-signed-out"
|
| 23 |
onclick = (
|
| 24 |
"const q=new URLSearchParams(window.location.search);"
|
| 25 |
"q.set('birdnet_login_intent','1');"
|
|
|
|
| 31 |
return (
|
| 32 |
"<div class='bn-oauth-login-html' "
|
| 33 |
"style='box-sizing:border-box;width:100%;max-width:var(--bn-login-width,680px);margin:0 auto;'>"
|
| 34 |
+
f"<a class='bn-hf-oauth-link {state_class}' href='{href}' target='_self' onclick=\"{onclick}\" "
|
| 35 |
+
f"aria-label='{label}'>"
|
| 36 |
+
"<span class='bn-hf-oauth-mark' aria-hidden='true'>HF</span>"
|
| 37 |
+
f"<span class='bn-hf-oauth-label'>{label}</span>"
|
|
|
|
|
|
|
|
|
|
| 38 |
"</a>"
|
| 39 |
"</div>"
|
| 40 |
)
|
src/ui/theme.py
CHANGED
|
@@ -65,6 +65,39 @@ main.app,
|
|
| 65 |
margin-right: auto !important;
|
| 66 |
}
|
| 67 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 68 |
@media (max-width: 1280px) {
|
| 69 |
:root {
|
| 70 |
--bn-content-width: calc(100vw - 32px);
|
|
@@ -290,6 +323,66 @@ button.bn-oauth-login-button * {
|
|
| 290 |
white-space: nowrap !important;
|
| 291 |
}
|
| 292 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 293 |
.bn-panel {
|
| 294 |
box-sizing: border-box;
|
| 295 |
width: 100%;
|
|
|
|
| 65 |
margin-right: auto !important;
|
| 66 |
}
|
| 67 |
|
| 68 |
+
.bn-hf-oauth-link {
|
| 69 |
+
box-sizing: border-box !important;
|
| 70 |
+
display: inline-flex !important;
|
| 71 |
+
align-items: center !important;
|
| 72 |
+
justify-content: center !important;
|
| 73 |
+
gap: 10px !important;
|
| 74 |
+
width: 100% !important;
|
| 75 |
+
min-height: 48px !important;
|
| 76 |
+
padding: 12px 18px !important;
|
| 77 |
+
border: 1px solid #d0d7de !important;
|
| 78 |
+
border-radius: 8px !important;
|
| 79 |
+
background: #ffffff !important;
|
| 80 |
+
color: #142033 !important;
|
| 81 |
+
font-weight: 760 !important;
|
| 82 |
+
text-decoration: none !important;
|
| 83 |
+
white-space: nowrap !important;
|
| 84 |
+
box-shadow: 0 1px 2px rgba(20, 32, 51, 0.05) !important;
|
| 85 |
+
}
|
| 86 |
+
|
| 87 |
+
.bn-hf-oauth-mark {
|
| 88 |
+
display: inline-flex !important;
|
| 89 |
+
align-items: center !important;
|
| 90 |
+
justify-content: center !important;
|
| 91 |
+
width: 26px !important;
|
| 92 |
+
height: 26px !important;
|
| 93 |
+
border-radius: 999px !important;
|
| 94 |
+
background: #ffd166 !important;
|
| 95 |
+
color: #503500 !important;
|
| 96 |
+
font-size: 11px !important;
|
| 97 |
+
font-weight: 850 !important;
|
| 98 |
+
letter-spacing: 0 !important;
|
| 99 |
+
}
|
| 100 |
+
|
| 101 |
@media (max-width: 1280px) {
|
| 102 |
:root {
|
| 103 |
--bn-content-width: calc(100vw - 32px);
|
|
|
|
| 323 |
white-space: nowrap !important;
|
| 324 |
}
|
| 325 |
|
| 326 |
+
.bn-hf-oauth-link {
|
| 327 |
+
box-sizing: border-box !important;
|
| 328 |
+
display: inline-flex !important;
|
| 329 |
+
align-items: center !important;
|
| 330 |
+
justify-content: center !important;
|
| 331 |
+
gap: 10px !important;
|
| 332 |
+
width: 100% !important;
|
| 333 |
+
max-width: var(--bn-login-width) !important;
|
| 334 |
+
min-height: 48px !important;
|
| 335 |
+
padding: 12px 18px !important;
|
| 336 |
+
border: 1px solid #d0d7de !important;
|
| 337 |
+
border-radius: 8px !important;
|
| 338 |
+
background: #ffffff !important;
|
| 339 |
+
color: var(--bn-text) !important;
|
| 340 |
+
font-weight: 760 !important;
|
| 341 |
+
text-decoration: none !important;
|
| 342 |
+
white-space: nowrap !important;
|
| 343 |
+
box-shadow: 0 1px 2px rgba(20, 32, 51, 0.05) !important;
|
| 344 |
+
transition: background 120ms ease, border-color 120ms ease, box-shadow 120ms ease, transform 120ms ease !important;
|
| 345 |
+
}
|
| 346 |
+
|
| 347 |
+
.bn-hf-oauth-link:hover,
|
| 348 |
+
.bn-hf-oauth-link:focus-visible {
|
| 349 |
+
border-color: #f59e0b !important;
|
| 350 |
+
background: #fffaf0 !important;
|
| 351 |
+
color: var(--bn-text) !important;
|
| 352 |
+
box-shadow: 0 6px 18px rgba(20, 32, 51, 0.08) !important;
|
| 353 |
+
text-decoration: none !important;
|
| 354 |
+
}
|
| 355 |
+
|
| 356 |
+
.bn-hf-oauth-link:active {
|
| 357 |
+
transform: translateY(1px) !important;
|
| 358 |
+
}
|
| 359 |
+
|
| 360 |
+
.bn-hf-oauth-mark {
|
| 361 |
+
display: inline-flex !important;
|
| 362 |
+
align-items: center !important;
|
| 363 |
+
justify-content: center !important;
|
| 364 |
+
flex: 0 0 auto !important;
|
| 365 |
+
width: 26px !important;
|
| 366 |
+
height: 26px !important;
|
| 367 |
+
border-radius: 999px !important;
|
| 368 |
+
background: #ffd166 !important;
|
| 369 |
+
color: #503500 !important;
|
| 370 |
+
font-size: 11px !important;
|
| 371 |
+
font-weight: 850 !important;
|
| 372 |
+
letter-spacing: 0 !important;
|
| 373 |
+
line-height: 1 !important;
|
| 374 |
+
}
|
| 375 |
+
|
| 376 |
+
.bn-hf-oauth-label {
|
| 377 |
+
overflow: hidden !important;
|
| 378 |
+
text-overflow: ellipsis !important;
|
| 379 |
+
}
|
| 380 |
+
|
| 381 |
+
.bn-hf-oauth-link-signed-in .bn-hf-oauth-mark {
|
| 382 |
+
background: #e0f2fe !important;
|
| 383 |
+
color: var(--bn-info) !important;
|
| 384 |
+
}
|
| 385 |
+
|
| 386 |
.bn-panel {
|
| 387 |
box-sizing: border-box;
|
| 388 |
width: 100%;
|
tests/unit/test_login_page.py
CHANGED
|
@@ -76,6 +76,7 @@ def test_oauth_action_button_html_has_fixed_width_and_intent_route() -> None:
|
|
| 76 |
|
| 77 |
assert "max-width:var(--bn-login-width,680px)" in signed_out
|
| 78 |
assert "/login/huggingface?birdnet_login_intent=1" in signed_out
|
|
|
|
| 79 |
assert "birdnet_hf_login_intent" in signed_out
|
| 80 |
assert "Sign out" in signed_in
|
| 81 |
assert "/logout" in signed_in
|
|
|
|
| 76 |
|
| 77 |
assert "max-width:var(--bn-login-width,680px)" in signed_out
|
| 78 |
assert "/login/huggingface?birdnet_login_intent=1" in signed_out
|
| 79 |
+
assert "bn-hf-oauth-link" in signed_out
|
| 80 |
assert "birdnet_hf_login_intent" in signed_out
|
| 81 |
assert "Sign out" in signed_in
|
| 82 |
assert "/logout" in signed_in
|