fix user validation

This commit is contained in:
2025-04-08 10:33:03 +08:00
parent 6749ff636d
commit 12f12a82b5
2 changed files with 40 additions and 12 deletions

View File

@@ -1,12 +1,25 @@
import { decrypt } from "@/app/(auth)/_lib/decrypt";
import { prisma } from "@/lib";
import { NextRequest, NextResponse } from "next/server";
import { cookies } from "next/headers";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export async function GET(req: NextRequest) {
export async function GET(req: Request) {
try {
const token = req.headers.get("Authorization")?.split(" ")[1];
const SESSIONKEY = process.env.NEXT_PUBLIC_BASE_SESSION_KEY!;
// const token = req.headers.get("Authorization")?.split(" ")[1]
const token =
cookies().get(SESSIONKEY)?.value ||
req.headers.get("Authorization")?.split(" ")[1];
if (!token) {
return NextResponse.json(
{
success: false,
message: "Unauthorized token not found",
},
{ status: 401 }
);
}
const decripted = await decrypt({
token: token!,