移除旧版用户兼容

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
+7 -21
View File
@@ -34,31 +34,17 @@ export async function GET(request: NextRequest) {
if (username === process.env.USERNAME) {
result.Role = 'owner';
} else {
// 优先从新版获取用户信息
// 从新版数据库获取用户信息
const { db } = await import('@/lib/db');
const userInfoV2 = await db.getUserInfoV2(username);
if (userInfoV2) {
// 使用新版本用户信息
if (userInfoV2.role === 'admin' && !userInfoV2.banned) {
result.Role = 'admin';
} else {
return NextResponse.json(
{ error: '你是管理员吗你就访问?' },
{ status: 401 }
);
}
if (userInfoV2 && userInfoV2.role === 'admin' && !userInfoV2.banned) {
result.Role = 'admin';
} else {
// 回退到配置中查找
const user = config.UserConfig.Users.find((u) => u.username === username);
if (user && user.role === 'admin' && !user.banned) {
result.Role = 'admin';
} else {
return NextResponse.json(
{ error: '你是管理员吗你就访问?' },
{ status: 401 }
);
}
return NextResponse.json(
{ error: '你是管理员吗你就访问?' },
{ status: 401 }
);
}
}