Skip to content

Never stop coding. Free MIT AI gateway: one endpoint, 375 providers (150+ free), 1,400+ models Kimi, Claude, GPT, Gemini, GLM, DeepSeek, MiniMax. Works with Claude Code, Codex, Cursor, OpenCode, Cline & Copilot. Quota-aware auto-fallback, RTK+Caveman compression saves 15-95% tokens, MCP/A2A, Desktop/PWA. Built by 900+ contributors

fix(auth): allow INITIAL_PASSWORD when updating first password

jackdaaa3a8782dc
diff --git a/src/app/api/settings/route.ts b/src/app/api/settings/route.ts
index cb0511c6d8..bcfa59445d 100644
--- a/src/app/api/settings/route.ts
+++ b/src/app/api/settings/route.ts
@@ -60,9 +60,13 @@ export async function PATCH(request) {
return NextResponse.json({ error: "Invalid current password" }, { status: 401 });
}
} else {
- // First time setting password, no current password needed
- // Allow empty currentPassword or default "123456"
- if (body.currentPassword && body.currentPassword !== "123456") {
+ // First-time password set (no DB hash yet).
+ // Accept empty current password, legacy default, or INITIAL_PASSWORD when configured.
+ const initialPassword = process.env.INITIAL_PASSWORD;
+ const currentPassword = body.currentPassword || "";
+ const allowedWithoutHash = ["", "123456", ...(initialPassword ? [initialPassword] : [])];
+
+ if (!allowedWithoutHash.includes(currentPassword)) {
return NextResponse.json({ error: "Invalid current password" }, { status: 401 });
}
}