From f9b084d09ddf441410e0285231894a5a531e19b7 Mon Sep 17 00:00:00 2001 From: shuaiplus <2327005759@qq.com> Date: Wed, 25 Feb 2026 01:30:08 +0800 Subject: [PATCH] feat: remove setup disabling functionality and related UI elements --- src/handlers/setup.ts | 31 ++------ src/router.ts | 10 +-- src/services/storage.ts | 11 --- src/setup/pageTemplate.ts | 145 +------------------------------------- 4 files changed, 8 insertions(+), 189 deletions(-) diff --git a/src/handlers/setup.ts b/src/handlers/setup.ts index 4824485..5389ee3 100644 --- a/src/handlers/setup.ts +++ b/src/handlers/setup.ts @@ -1,6 +1,6 @@ import { Env, DEFAULT_DEV_SECRET } from '../types'; import { StorageService } from '../services/storage'; -import { jsonResponse, errorResponse, htmlResponse } from '../utils/response'; +import { jsonResponse, htmlResponse } from '../utils/response'; import { renderRegisterPageHTML } from '../setup/pageTemplate'; import { LIMITS } from '../config/limits'; @@ -16,42 +16,21 @@ function getJwtSecretState(env: Env): JwtSecretState | null { } async function handleRegisterPage(request: Request, env: Env, jwtState: JwtSecretState | null): Promise { - const storage = new StorageService(env.DB); - const disabled = await storage.isSetupDisabled(); - if (disabled) { - return new Response(null, { status: 404 }); - } + void request; + void env; return htmlResponse(renderRegisterPageHTML(jwtState)); } // GET / - Setup page export async function handleSetupPage(request: Request, env: Env): Promise { - const storage = new StorageService(env.DB); - const disabled = await storage.isSetupDisabled(); - if (disabled) { - return new Response(null, { status: 404 }); - } - - // 引导页内会处理 JWT_SECRET 检测与分流(坏密钥停留在修复步骤)。 const jwtState = getJwtSecretState(env); return handleRegisterPage(request, env, jwtState); } // GET /setup/status export async function handleSetupStatus(request: Request, env: Env): Promise { + void request; const storage = new StorageService(env.DB); const registered = await storage.isRegistered(); - const disabled = await storage.isSetupDisabled(); - return jsonResponse({ registered, disabled }); -} - -// POST /setup/disable -export async function handleDisableSetup(request: Request, env: Env): Promise { - const storage = new StorageService(env.DB); - const registered = await storage.isRegistered(); - if (!registered) { - return errorResponse('Registration required', 403); - } - await storage.setSetupDisabled(); - return jsonResponse({ success: true }); + return jsonResponse({ registered }); } diff --git a/src/router.ts b/src/router.ts index f34a6ca..0b58c76 100644 --- a/src/router.ts +++ b/src/router.ts @@ -37,7 +37,7 @@ import { import { handleSync } from './handlers/sync'; // Setup handlers -import { handleSetupPage, handleSetupStatus, handleDisableSetup } from './handlers/setup'; +import { handleSetupPage, handleSetupStatus } from './handlers/setup'; import { handleKnownDevice, handleGetDevices, handleUpdateDeviceToken } from './handlers/devices'; // Import handler @@ -176,14 +176,6 @@ export async function handleRequest(request: Request, env: Env): Promise { - const row = await this.db.prepare('SELECT value FROM config WHERE key = ?').bind('setup_disabled').first<{ value: string }>(); - return row?.value === 'true'; - } - - async setSetupDisabled(): Promise { - await this.db.prepare('INSERT INTO config(key, value) VALUES(?, ?) ON CONFLICT(key) DO UPDATE SET value = excluded.value') - .bind('setup_disabled', 'true') - .run(); - } - // --- Users --- async getUser(email: string): Promise { diff --git a/src/setup/pageTemplate.ts b/src/setup/pageTemplate.ts index 19b5bb1..32ae216 100644 --- a/src/setup/pageTemplate.ts +++ b/src/setup/pageTemplate.ts @@ -452,52 +452,6 @@ export function renderRegisterPageHTML(jwtState: JwtSecretState | null): string color: var(--muted2); } - .modal-mask { - position: fixed; - inset: 0; - background: rgba(16, 24, 40, 0.45); - display: none; - align-items: center; - justify-content: center; - z-index: 9999; - padding: 20px; - } - .modal-mask.show { display: flex; } - .modal { - width: min(520px, 100%); - border-radius: 16px; - border: 1px solid var(--border); - background: #ffffff; - box-shadow: 0 24px 56px rgba(16, 24, 40, 0.18); - padding: 20px; - } - .modal h3 { - margin: 0 0 8px 0; - font-size: 18px; - color: #101828; - } - .modal p { - margin: 0; - font-size: 15px; - line-height: 1.7; - color: #475467; - } - .modal-warn { - margin-top: 10px; - border: 1px solid #fecdca; - background: #fff6f5; - color: #b42318; - border-radius: 12px; - padding: 10px 12px; - font-size: 14px; - line-height: 1.6; - } - .modal-actions { - margin-top: 16px; - display: flex; - justify-content: flex-end; - gap: 8px; - } @@ -696,13 +650,6 @@ export function renderRegisterPageHTML(jwtState: JwtSecretState | null): string

Your server is ready. Configure your Bitwarden client with this server URL:

-
-

Hide setup page

-

-
- -
-
@@ -731,18 +678,6 @@ export function renderRegisterPageHTML(jwtState: JwtSecretState | null): string - -