Fix: middleware

Deskripsi
- Fix middleware
- Fix metode login ( sekarang menggunakan api )
This commit is contained in:
2024-12-02 16:24:03 +08:00
parent 45279cd37f
commit 31124c5500
55 changed files with 1675 additions and 420 deletions

View File

@@ -0,0 +1,22 @@
"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_checkActivationUseById({
userId,
}: {
userId: string;
}) {
const data = await prisma.user.findFirst({
where: {
id: userId,
},
select: {
active: true,
},
});
return data?.active;
}

View File

@@ -1,26 +1,27 @@
"use server";
import { prisma } from "@/app/lib";
import { ServerEnv } from "@/app/lib/server_env";
import { unsealData } from "iron-session";
import { cookies } from "next/headers";
export async function funGetUserIdByToken() {
const c = cookies().get("mySession");
const c = cookies().get(process.env.NEXT_PUBLIC_BASE_SESSION_KEY!);
const token = JSON.parse(
await unsealData(c?.value as string, {
password: process.env.WIBU_PWD as string,
})
);
// const token = JSON.parse(
// await unsealData(c?.value as string, {
// password: process.env.WIBU_PWD as string,
// })
// );
// return token.id;
return token.id;
// const token = c?.value
// const cekToken = await prisma.userSession.findFirst({
// where: {
// token: token,
// },
// });
const token = c?.value
const cekToken = await prisma.userSession.findFirst({
where: {
token: token,
},
});
// if (cekToken === null) return null
// return cekToken.userId;
return cekToken?.userId
}