Fix: Cookies

Deksripsi:
- Perbaikan cookies untuk server
This commit is contained in:
2024-11-21 11:41:31 +08:00
parent a9cb6bc59b
commit abaec2c1c3
55 changed files with 1519 additions and 1401 deletions

View File

@@ -1,8 +1,12 @@
"use server";
import { prisma } from "@/app/lib";
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
import { permanentRedirect } from "next/navigation";
export async function funGlobal_getUserById({ userId }: { userId: string }) {
if (!userId) return permanentRedirect(RouterAuth.login);
const data = await prisma.user.findFirst({
where: {
id: userId,

View File

@@ -1,18 +1,17 @@
"use server";
import { cookies } from "next/headers";
import prisma from "@/app/lib/prisma";
import { redirect } from "next/navigation";
import { RouterAuth } from "@/app/lib/router_hipmi/router_auth";
import { cookies } from "next/headers";
export async function funGetUserIdByToken() {
const c = cookies().get("ssn");
const token = c?.value
const cekToken = await prisma.userSession.findFirst({
where: {
token: c?.value,
token: token,
},
});
if (cekToken === null) return redirect(RouterAuth.login);
if (cekToken === null) return null
return cekToken.userId;
}