修改登录逻辑

This commit is contained in:
2026-07-06 15:54:27 +08:00
parent fe66794168
commit 53b1842de8
12 changed files with 198 additions and 28 deletions

View File

@@ -21,10 +21,6 @@ type PasswordTokenResponse = {
export async function POST(request: Request) {
try {
const config = getAuthRuntimeConfig();
if (!config.configured || !config.tokenUrl || !config.clientSecret || !config.sessionSecret) {
throw new PasswordLoginError(`认证配置不完整:${config.missing.join(", ") || "未知配置"}`, 500);
}
const body = await readJsonBody<{
username?: string;
password?: string;
@@ -33,7 +29,12 @@ export async function POST(request: Request) {
code?: string;
randomStr?: string;
next?: string;
authMode?: string;
}>(request);
const config = getAuthRuntimeConfig({ clientMode: body.authMode === "admin" ? "admin" : "default" });
if (!config.configured || !config.tokenUrl || !config.clientSecret || !config.sessionSecret) {
throw new PasswordLoginError(`认证配置不完整:${config.missing.join(", ") || "未知配置"}`, 500);
}
const username = body.username?.trim();
const password = body.password || "";
const code = body.code?.trim();