Fix: middleware
Deskripsi - Fix middleware - Fix metode login ( sekarang menggunakan api )
This commit is contained in:
@@ -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;
|
||||
}
|
||||
@@ -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
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user