mirror of
https://github.com/ChatGPTNextWeb/ChatGPT-Next-Web.git
synced 2025-11-16 14:03:43 +08:00
认证中间状态
This commit is contained in:
@@ -1,15 +1,14 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import prisma from "@/lib/prisma";
|
||||
import { getSessionName } from "@/lib/auth";
|
||||
import { ADMIN_LIST } from "@/lib/auth_list";
|
||||
import { VerifiedAdminUser } from "@/lib/auth";
|
||||
|
||||
async function handle(
|
||||
req: NextRequest,
|
||||
{ params }: { params: { path: string[] } },
|
||||
) {
|
||||
// 认证,管理员权限
|
||||
const { name } = await getSessionName();
|
||||
if (!(name && ADMIN_LIST.includes(name))) {
|
||||
const isAdmin = await VerifiedAdminUser();
|
||||
if (isAdmin) {
|
||||
return NextResponse.json({ error: "无权限" }, { status: 401 });
|
||||
}
|
||||
|
||||
|
||||
@@ -150,7 +150,6 @@ export async function requestLog(
|
||||
req: NextRequest,
|
||||
jsonBody: any,
|
||||
url_path: string,
|
||||
name?: string,
|
||||
) {
|
||||
// LOG
|
||||
try {
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { NextRequest, NextResponse } from "next/server";
|
||||
import { getSession } from "@/lib/auth";
|
||||
import { VerifiedUser } from "@/lib/auth";
|
||||
import { getServerSideConfig } from "@/app/config/server";
|
||||
const serverConfig = getServerSideConfig();
|
||||
// Gets an access token.
|
||||
@@ -21,9 +21,8 @@ async function handle(
|
||||
) {
|
||||
// 认证
|
||||
|
||||
const session = await getSession();
|
||||
if (!session?.user)
|
||||
return NextResponse.json({ error: "未认证" }, { status: 401 });
|
||||
const isUser = await VerifiedUser();
|
||||
if (!isUser) return NextResponse.json({ error: "未认证" }, { status: 401 });
|
||||
|
||||
const get_access_token = await getAccessToken();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user