fix
Deskripsi: - Upload ke stroage untuk job ## Np Issuee
This commit is contained in:
@@ -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: {} };
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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" };
|
||||
}
|
||||
|
||||
@@ -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" };
|
||||
}
|
||||
|
||||
@@ -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) {
|
||||
|
||||
@@ -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,
|
||||
},
|
||||
});
|
||||
|
||||
|
||||
@@ -28,7 +28,6 @@ import {
|
||||
|
||||
export default function Login() {
|
||||
const router = useRouter();
|
||||
const [kodeId, setKodeId] = useAtom(gs_kodeId);
|
||||
const [phone, setPhone] = useState("");
|
||||
const [loading, setLoading] = useState(false);
|
||||
const [isError, setError] = useState(false);
|
||||
@@ -41,7 +40,7 @@ export default function Login() {
|
||||
if (res.status === 200) {
|
||||
setLoading(true);
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message, 2000);
|
||||
router.push(RouterAuth.validasi + res.nomorUser, { scroll: false });
|
||||
router.push(RouterAuth.validasi + res.kodeId, { scroll: false });
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
|
||||
@@ -6,23 +6,19 @@ import { ComponentGlobal_NotifikasiPeringatan } from "@/app_modules/_global/noti
|
||||
import UIGlobal_Modal from "@/app_modules/_global/ui/ui_modal";
|
||||
import { ActionIcon, Button, Stack, Text } from "@mantine/core";
|
||||
import { IconLogout } from "@tabler/icons-react";
|
||||
import { useAtom } from "jotai";
|
||||
import { useRouter } from "next/navigation";
|
||||
import { useState } from "react";
|
||||
import { auth_Logout } from "../fun/fun_logout";
|
||||
import { gs_kodeId } from "../state/state";
|
||||
|
||||
export default function Component_Logout() {
|
||||
const router = useRouter();
|
||||
const [opened, setOpened] = useState(false);
|
||||
const [kodeId, setKodeId] = useAtom(gs_kodeId);
|
||||
const [loading, setLoading] = useState(false);
|
||||
|
||||
async function onClickLogout() {
|
||||
await auth_Logout(kodeId).then((res) => {
|
||||
await auth_Logout().then((res) => {
|
||||
if (res.status === 200) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
setKodeId("");
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
}
|
||||
|
||||
@@ -61,10 +61,20 @@ export default function Validasi({ dataOtp }: { dataOtp: any }) {
|
||||
} else {
|
||||
ComponentGlobal_NotifikasiPeringatan(resAktivasi.message);
|
||||
}
|
||||
} else {
|
||||
}
|
||||
|
||||
if (res.status === 400) {
|
||||
ComponentGlobal_NotifikasiBerhasil(res.message);
|
||||
router.push(RouterAuth.register + dataOtp.id, { scroll: false });
|
||||
}
|
||||
|
||||
if (res.status === 401) {
|
||||
const resAktivasi = await auth_funDeleteAktivasiKodeOtpById(dataOtp.id);
|
||||
if (resAktivasi.status === 200) {
|
||||
ComponentGlobal_NotifikasiPeringatan(res.message);
|
||||
router.push(RouterAuth.login, { scroll: false });
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return (
|
||||
|
||||
Reference in New Issue
Block a user