feat: tambah dependensi 'jose' versi 5.9.2 pada package.json

refactor: rapikan identasi dan buat field 'expires' opsional di model UserSession pada schema prisma

chore: bersihkan import tidak terpakai di route login dan register API
This commit is contained in:
2024-09-18 14:39:39 +08:00
parent 2ccbca6566
commit 6ee43ed20f
83 changed files with 794 additions and 273 deletions

View File

@@ -1,8 +1,4 @@
import { redirect } from "next/navigation";
import { myConsole } from "@/app/fun/my_console";
import prisma from "@/app/lib/prisma";
import { RouterAdminDashboard } from "@/app/lib/router_hipmi/router_admin";
import { NextResponse } from "next/server";

View File

@@ -1,6 +1,5 @@
import { myConsole } from "@/app/fun/my_console";
import { PwdCookies } from "@/app/lib";
import prisma from "@/app/lib/prisma";
import { ServerEnv } from "@/app/lib/server_env";
import { sealData } from "iron-session";
import { cookies } from "next/headers";
import { NextResponse } from "next/server";
@@ -16,8 +15,6 @@ export async function POST(req: Request) {
},
});
myConsole(cekUsername);
if (cekUsername)
return NextResponse.json({ status: 400, message: "Username sudah ada" });
@@ -35,7 +32,7 @@ export async function POST(req: Request) {
username: data.username,
}),
{
password: PwdCookies,
password: ServerEnv.value?.WIBU_PWD as string,
}
);

View File

@@ -1,6 +1,5 @@
import { myConsole } from "@/app/fun/my_console";
import { PwdCookies } from "@/app/lib";
import prisma from "@/app/lib/prisma";
import { ServerEnv } from "@/app/lib/server_env";
import { sealData } from "iron-session";
import { revalidatePath } from "next/cache";
import { cookies } from "next/headers";
@@ -22,8 +21,6 @@ export async function POST(req: Request) {
},
});
myConsole(data);
if (!data) return NextResponse.json({ status: 404 });
if (data) {
@@ -33,7 +30,7 @@ export async function POST(req: Request) {
username: data.username,
}),
{
password: await PwdCookies,
password: ServerEnv.value?.WIBU_PWD as string,
}
);

View File

@@ -0,0 +1,19 @@
import _ from "lodash";
import { cookies } from "next/headers";
export async function GET(req: Request) {
try {
const cekCookies = cookies();
const c = cekCookies.get("ssn");
if (!c || !c?.value || _.isEmpty(c?.value) || _.isUndefined(c?.value)) {
return Response.json({ success: false });
}
return Response.json({ success: true });
} catch (error) {
console.log(error);
}
return Response.json({ success: false });
}