Deskripsi:
- Upload ke stroage untuk job
## Np Issuee
This commit is contained in:
2024-09-19 15:59:21 +08:00
parent 128dc98839
commit f96d80d55d
153 changed files with 1369 additions and 1200 deletions

View File

@@ -17,7 +17,7 @@ export async function auth_funLogin({ nomor }: { nomor: string }) {
const sendWa = await res.json();
if (sendWa.status !== "success")
return { status: 400, message: "WA Tidak Terdaftar", nomorUser: {} };
return { status: 400, message: "WA Tidak Terdaftar", kodeId: {} };
const createOtpId = await prisma.kodeOtp.create({
data: {
@@ -27,15 +27,15 @@ export async function auth_funLogin({ nomor }: { nomor: string }) {
});
if (!createOtpId)
return { status: 400, message: "Gagal Membuat Kode OTP", nomorUser: {} };
return { status: 400, message: "Gagal Membuat Kode OTP", kodeId: {} };
return {
status: 200,
message: "Kode Verifikasi Dikirim",
nomorUser: nomor,
kodeId: createOtpId.id,
};
} catch (error) {
console.log(error);
return { status: 500, message: "Server Error !!!", nomorUser: {} };
return { status: 500, message: "Server Error !!!", kodeId: {} };
}
}

View File

@@ -5,7 +5,7 @@ import { funGetUserIdByToken } from "@/app_modules/_global/fun/get";
import { revalidatePath } from "next/cache";
import { cookies } from "next/headers";
export async function auth_Logout(kodeId: string) {
export async function auth_Logout() {
const userId = await funGetUserIdByToken();
try {
@@ -19,8 +19,7 @@ export async function auth_Logout(kodeId: string) {
cookies().set({
name: "ssn",
value: "",
maxAge: 0,
expires: 0,
});
return { status: 200, message: "Logout Berhasil" };
@@ -28,12 +27,6 @@ export async function auth_Logout(kodeId: string) {
console.log(error);
}
// const del = await prisma.kodeOtp.delete({
// where: {
// id: kodeId,
// },
// });
// if (!del) return { status: 400, message: "Gagal Hapus Kode OTP Id"};
// revalidatePath("/dev/katalog")
revalidatePath("/");
return { status: 200, message: "Logout Berhasil" };
}

View File

@@ -1,7 +1,9 @@
"use server";
import prisma from "@/app/lib/prisma";
import { RouterHome } from "@/app/lib/router_hipmi/router_home";
import { sealData } from "iron-session";
import { revalidatePath } from "next/cache";
import { cookies } from "next/headers";
export async function Auth_funRegister({
@@ -47,15 +49,20 @@ export async function Auth_funRegister({
// maxAge: 60 * 60 * 24 * 7,
});
const createUserSession = await prisma.userSession.create({
data: {
token: sealToken,
userId: create.id,
},
});
try {
const createUserSession = await prisma.userSession.create({
data: {
token: sealToken,
userId: create.id,
},
});
if (!createUserSession)
return { status: 400, message: "Gagal Membuat User Session" };
if (!createUserSession)
return { status: 401, message: "Gagal Membuat User Session" };
revalidatePath(RouterHome.main_home);
} catch (error) {
console.log(error);
}
return { status: 200, message: "Berhasil Mendaftar" };
}

View File

@@ -25,7 +25,8 @@ export async function auth_funValidasi({
},
});
if (cekUser === null) return { status: 400, message: "Nomor Belum Terdaftar" };
if (cekUser === null)
return { status: 400, message: "Nomor Belum Terdaftar", role: {} };
const sealToken = await sealData(
JSON.stringify({
@@ -40,10 +41,23 @@ export async function auth_funValidasi({
cookies().set({
name: "ssn",
value: sealToken,
// maxAge: 60 * 60 * 24 * 30,
// expires: 60 * 60 * 24 * 30,
maxAge: 60 * 60 * 24 * 30,
});
const cekSessionUser = await prisma.userSession.findFirst({
where: {
userId: cekUser.id,
},
});
if (cekSessionUser !== null) {
await prisma.userSession.delete({
where: {
userId: cekUser.id,
},
});
}
try {
const createUserSession = await prisma.userSession.create({
data: {
@@ -53,7 +67,7 @@ export async function auth_funValidasi({
});
if (!createUserSession)
return { status: 401, message: "Gagal Membuat User Session" };
return { status: 401, message: "Gagal Membuat User Session", role: {} };
revalidatePath(RouterHome.main_home);
} catch (error) {

View File

@@ -2,10 +2,10 @@
import prisma from "@/app/lib/prisma";
export async function auth_getKodeOtpById({nomor}: {nomor: string}) {
export async function auth_getCodeOtpByNumber({kodeId}: {kodeId: string}) {
const data = await prisma.kodeOtp.findFirst({
where: {
nomor: nomor,
id: kodeId,
},
});