用户组增加权限控制

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';
@@ -16,7 +17,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 }
+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';
@@ -17,7 +18,7 @@ export const runtime = 'nodejs';
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 }
+2 -1
View File
@@ -4,6 +4,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { OpenListClient } from '@/lib/openlist.client';
import { hasFeaturePermission } from '@/lib/permissions';
export const runtime = 'nodejs';
@@ -15,7 +16,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_save_private_library'))) {
return NextResponse.json(
{ error: '无权限访问' },
{ status: 403 }
+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 }