From 6fb245194ee3cbc7866c6b55c0b2f732b6a6a8ab Mon Sep 17 00:00:00 2001 From: Codex Date: Thu, 14 May 2026 20:38:31 +0800 Subject: [PATCH] Remove embedded auth overlay from app pages --- public/app.js | 24 ++++-------------------- public/index.html | 9 --------- public/mobile.html | 9 --------- public/mobile.js | 24 ++++-------------------- test/access-password.test.js | 27 +++++++++++++-------------- 5 files changed, 21 insertions(+), 72 deletions(-) diff --git a/public/app.js b/public/app.js index 9c5a2d2..2c8e93f 100644 --- a/public/app.js +++ b/public/app.js @@ -1,7 +1,4 @@ const HOTNESS_AUTH_TOKEN_KEY = "video-hotness-auth-token-v1"; -const authGate = document.querySelector("#auth-gate"); -const authPassword = document.querySelector("#auth-password"); -const authMessage = document.querySelector("#auth-message"); const form = document.querySelector("#collect-form"); const input = document.querySelector("#program-name"); const button = document.querySelector("#collect-button"); @@ -2135,11 +2132,10 @@ async function ensureAccessAuth() { const response = await fetch("/api/auth/status", { headers: authHeaders() }); const payload = await response.json(); if (!payload.enabled || payload.authorized) { - hideAuthGate(); return true; } } catch {} - showAuthGate(""); + redirectToLogin(); return false; } @@ -2151,24 +2147,12 @@ function authHeaders() { function handleAuthFailure(response, payload) { if (response.status !== 401 || !payload?.requires_auth) return false; localStorage.removeItem(HOTNESS_AUTH_TOKEN_KEY); - showAuthGate(payload.error || "需要输入访问密码"); + redirectToLogin(); return true; } -function showAuthGate(message = "") { - if (!authGate) return; - authGate.hidden = false; - setAuthMessage(message); - requestAnimationFrame(() => authPassword?.focus()); -} - -function hideAuthGate() { - if (authGate) authGate.hidden = true; - setAuthMessage(""); -} - -function setAuthMessage(message) { - if (authMessage) authMessage.textContent = message || ""; +function redirectToLogin() { + window.location.href = "/"; } function setBusy(isBusy, text = "") { diff --git a/public/index.html b/public/index.html index 10c7b70..f0cee38 100644 --- a/public/index.html +++ b/public/index.html @@ -8,15 +8,6 @@ -