用户组增加权限控制

This commit is contained in:
mtvpls
2026-04-22 16:22:17 +08:00
parent 2734de0c85
commit 0916e4ff08
61 changed files with 617 additions and 165 deletions
+2 -1
View File
@@ -5,6 +5,7 @@ import { parseStringPromise } from 'xml2js';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { getMagnetBaseUrl, universalMagnetFetch } from '@/lib/magnet.client';
import { hasFeaturePermission } from '@/lib/permissions';
export const runtime = 'nodejs';
@@ -22,7 +23,7 @@ export async function POST(req: NextRequest) {
try {
// 检查权限
const authInfo = getAuthInfoFromCookie(req);
if (!authInfo || (authInfo.role !== 'admin' && authInfo.role !== 'owner')) {
if (!authInfo?.username || !(await hasFeaturePermission(authInfo.username, 'magnet_search'))) {
return NextResponse.json(
{ error: '无权限访问' },
{ status: 403 }