移除旧版用户兼容

This commit is contained in:
mtvpls
2026-01-24 18:17:19 +08:00
parent e0390cc0bc
commit aa10ebd638
6 changed files with 24 additions and 127 deletions
+2 -16
View File
@@ -202,12 +202,11 @@ export async function GET(request: NextRequest) {
}
// 检查用户是否已存在(通过OIDC sub查找)
// 优先使用新版本查找
let username = await db.getUserByOidcSub(oidcSub);
const username = await db.getUserByOidcSub(oidcSub);
let userRole: 'owner' | 'admin' | 'user' = 'user';
if (username) {
// 从新版本获取用户信息
// 获取用户信息
const userInfoV2 = await db.getUserInfoV2(username);
if (userInfoV2) {
userRole = userInfoV2.role;
@@ -218,19 +217,6 @@ export async function GET(request: NextRequest) {
);
}
}
} else {
// 回退到配置中查找
const existingUser = config.UserConfig.Users.find((u: any) => u.oidcSub === oidcSub);
if (existingUser) {
username = existingUser.username;
userRole = existingUser.role || 'user';
// 检查用户是否被封禁
if (existingUser.banned) {
return NextResponse.redirect(
new URL('/login?error=' + encodeURIComponent('用户被封禁'), origin)
);
}
}
}
if (username) {
@@ -176,7 +176,7 @@ export async function POST(request: NextRequest) {
);
}
// 检查用户名是否已存在(优先使用新版本)
// 检查用户名是否已存在
const userExists = await db.checkUserExistV2(username);
if (userExists) {
return NextResponse.json(
@@ -185,24 +185,8 @@ export async function POST(request: NextRequest) {
);
}
// 检查配置中是否已存在
const existingUser = config.UserConfig.Users.find((u) => u.username === username);
if (existingUser) {
return NextResponse.json(
{ error: '用户名已存在' },
{ status: 409 }
);
}
// 检查OIDC sub是否已被使用(优先使用新版本)
let existingOIDCUsername = await db.getUserByOidcSub(oidcSession.sub);
if (!existingOIDCUsername) {
// 回退到配置中查找
const existingOIDCUser = config.UserConfig.Users.find((u: any) => u.oidcSub === oidcSession.sub);
if (existingOIDCUser) {
existingOIDCUsername = existingOIDCUser.username;
}
}
// 检查OIDC sub是否已被使用
const existingOIDCUsername = await db.getUserByOidcSub(oidcSession.sub);
if (existingOIDCUsername) {
return NextResponse.json(
{ error: '该OIDC账号已被注册' },