Files
hipmi/src/app/api/user/route.ts
Bagasbanuna02 d7252b9fb3 fix folder
deskripsi:
- ganti nama folder (user) ke (auth)
- hapus folder auth
2025-02-05 15:34:06 +08:00

26 lines
698 B
TypeScript

import { decrypt } from "@/app/(auth)/_lib/decrypt";
import _ from "lodash";
import { cookies } from "next/headers";
import { NextResponse } from "next/server";
export const dynamic = "force-dynamic";
export async function GET() {
const c = cookies().get(process.env.NEXT_PUBLIC_BASE_SESSION_KEY!);
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
return NextResponse.json({ status: 401, message: "Unauthorized" });
}
const token = c.value;
const dataUser = await decrypt({
token: token,
encodedKey: process.env.NEXT_PUBLIC_BASE_TOKEN_KEY!,
});
const id = dataUser?.id
return NextResponse.json({ status: 200, message: "OK", data: id });
}