diff --git a/app/api/admin/users/[[...path]]/route.ts b/app/api/admin/users/[[...path]]/route.ts index b84667a1e..55fad8960 100644 --- a/app/api/admin/users/[[...path]]/route.ts +++ b/app/api/admin/users/[[...path]]/route.ts @@ -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 }); } diff --git a/app/api/common.ts b/app/api/common.ts index 6ec3017d5..5230413b4 100644 --- a/app/api/common.ts +++ b/app/api/common.ts @@ -150,7 +150,6 @@ export async function requestLog( req: NextRequest, jsonBody: any, url_path: string, - name?: string, ) { // LOG try { diff --git a/app/api/get_voice_token/route.ts b/app/api/get_voice_token/route.ts index 9e9bd5fda..07a8d6b5e 100644 --- a/app/api/get_voice_token/route.ts +++ b/app/api/get_voice_token/route.ts @@ -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(); diff --git a/app/app/(auth)/layout.tsx b/app/app/(auth)/layout.tsx index a964db852..60f219ccb 100644 --- a/app/app/(auth)/layout.tsx +++ b/app/app/(auth)/layout.tsx @@ -1,9 +1,8 @@ import "@/app/app/login.scss"; import { Metadata } from "next"; import { ReactNode } from "react"; -import { getSession } from "@/lib/auth"; -import { isName } from "@/lib/auth_list"; -import { redirect } from "next/navigation"; +// import { VerifiedUser } from "@/lib/auth"; +// import { redirect } from "next/navigation"; export const metadata: Metadata = { title: "Login | 实人认证", @@ -14,13 +13,11 @@ export default async function AuthLayout({ }: { children: ReactNode; }) { - const session = await getSession(); - // If the user is already authenticated, redirect them to home - const name = session?.user?.email || session?.user?.name; - if (name && isName(name)) { - // Replace '/dashboard' with the desired redirect path - redirect("/"); - } + // const isUser = await VerifiedUser(); + // if (isUser) { + // // Replace '/dashboard' with the desired redirect path + // redirect("/"); + // } return (