forked from PolarisPyra/cozynet
31 lines
662 B
TypeScript
31 lines
662 B
TypeScript
// check if user is authenticated
|
|
import { COOKIE_NAME } from "@/constants";
|
|
import { cookies } from "next/headers";
|
|
|
|
export async function GET() {
|
|
const cookieStore = cookies();
|
|
|
|
const token = cookieStore.get(COOKIE_NAME);
|
|
if (!token) {
|
|
return new Response("", { status: 401 });
|
|
}
|
|
|
|
// Remove the token verification part
|
|
// const { value } = token;
|
|
// const secret = process.env.JWT_SECRET || "";
|
|
// try {
|
|
// verify(value, secret);
|
|
|
|
const response = {
|
|
user: "Authenticated",
|
|
};
|
|
|
|
return new Response(JSON.stringify(response), {
|
|
status: 200,
|
|
});
|
|
|
|
// } catch (e) {
|
|
// return new Response("", { status: 400 });
|
|
// }
|
|
}
|