feat: add batch source and user operates

This commit is contained in:
shinya
2025-08-22 22:44:15 +08:00
parent aec039e42e
commit ca9a7403eb
8 changed files with 626 additions and 74 deletions

View File

@@ -25,12 +25,15 @@ export async function GET(request: NextRequest) {
}
const config = await getConfig();
if (config.UserConfig.Users) {
// 检查用户是否被封禁
if (authInfo.username !== process.env.ADMIN_USERNAME) {
// 非站长,检查用户存在或被封禁
const user = config.UserConfig.Users.find(
(u) => u.username === authInfo.username
);
if (user && user.banned) {
if (!user) {
return NextResponse.json({ error: '用户不存在' }, { status: 401 });
}
if (user.banned) {
return NextResponse.json({ error: '用户已被封禁' }, { status: 401 });
}
}
@@ -76,12 +79,15 @@ export async function POST(request: NextRequest) {
}
const config = await getConfig();
if (config.UserConfig.Users) {
// 检查用户是否被封禁
if (authInfo.username !== process.env.ADMIN_USERNAME) {
// 非站长,检查用户存在或被封禁
const user = config.UserConfig.Users.find(
(u) => u.username === authInfo.username
);
if (user && user.banned) {
if (!user) {
return NextResponse.json({ error: '用户不存在' }, { status: 401 });
}
if (user.banned) {
return NextResponse.json({ error: '用户已被封禁' }, { status: 401 });
}
}
@@ -144,12 +150,15 @@ export async function DELETE(request: NextRequest) {
}
const config = await getConfig();
if (config.UserConfig.Users) {
// 检查用户是否被封禁
if (authInfo.username !== process.env.ADMIN_USERNAME) {
// 非站长,检查用户存在或被封禁
const user = config.UserConfig.Users.find(
(u) => u.username === authInfo.username
);
if (user && user.banned) {
if (!user) {
return NextResponse.json({ error: '用户不存在' }, { status: 401 });
}
if (user.banned) {
return NextResponse.json({ error: '用户已被封禁' }, { status: 401 });
}
}