用户组增加权限控制

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
+3
View File
@@ -4,6 +4,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { requireFeaturePermission } from '@/lib/permissions';
import { XiaoyaClient } from '@/lib/xiaoya.client';
export const runtime = 'nodejs';
@@ -14,6 +15,8 @@ export const runtime = 'nodejs';
*/
export async function GET(request: NextRequest) {
try {
const authResult = await requireFeaturePermission(request, 'xiaoya', '无权限访问小雅');
if (authResult instanceof NextResponse) return authResult;
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo || !authInfo.username) {
return NextResponse.json({ error: '未授权' }, { status: 401 });
+3
View File
@@ -4,6 +4,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { requireFeaturePermission } from '@/lib/permissions';
import { XiaoyaClient } from '@/lib/xiaoya.client';
export const runtime = 'nodejs';
@@ -66,6 +67,8 @@ async function getFinalUrl(url: string, maxRedirects = 5): Promise<string> {
*/
export async function GET(request: NextRequest) {
try {
const authResult = await requireFeaturePermission(request, 'xiaoya', '无权限访问小雅');
if (authResult instanceof NextResponse) return authResult;
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo || !authInfo.username) {
return NextResponse.json({ error: '未授权' }, { status: 401 });
+3
View File
@@ -4,6 +4,7 @@ import { NextRequest, NextResponse } from 'next/server';
import { getAuthInfoFromCookie } from '@/lib/auth';
import { getConfig } from '@/lib/config';
import { requireFeaturePermission } from '@/lib/permissions';
export const runtime = 'nodejs';
@@ -13,6 +14,8 @@ export const runtime = 'nodejs';
*/
export async function GET(request: NextRequest) {
try {
const authResult = await requireFeaturePermission(request, 'xiaoya', '无权限访问小雅');
if (authResult instanceof NextResponse) return authResult;
const authInfo = getAuthInfoFromCookie(request);
if (!authInfo || !authInfo.username) {
return NextResponse.json({ error: '未授权' }, { status: 401 });