Fix: validasi

Deksripsi:
- Penambahan fitur kirim ulang kode
## No Issue
This commit is contained in:
2024-11-06 13:57:54 +08:00
parent 8cedf7db61
commit a6548f7b36
11 changed files with 580 additions and 484 deletions

View File

@@ -0,0 +1,40 @@
"use server";
import { prisma } from "@/app/lib";
import { randomOTP } from "./rondom_otp";
export async function auth_funResendCode({ nomor }: { nomor: string }) {
const codeOtp = randomOTP();
try {
const res = await fetch(
`https://wa.wibudev.com/code?nom=${nomor}&text=HIPMI - Kode ini bersifat RAHASIA dan JANGAN DI BAGIKAN KEPADA SIAPAPUN, termasuk anggota ataupun pengurus HIPMI lainnya.
\n
>> Kode OTP anda: ${codeOtp}.
`
);
const sendWa = await res.json();
if (sendWa.status !== "success")
return { status: 400, message: "WA Tidak Terdaftar", kodeId: {} };
const createOtpId = await prisma.kodeOtp.create({
data: {
nomor: nomor,
otp: codeOtp,
},
});
if (!createOtpId)
return { status: 400, message: "Gagal Membuat Kode OTP", kodeId: {} };
return {
status: 200,
message: "Kode Verifikasi Dikirim",
kodeId: createOtpId.id,
};
} catch (error) {
console.log(error);
return { status: 500, message: "Server Error !!!", kodeId: {} };
}
}

View File

@@ -0,0 +1,3 @@
import { auth_funResendCode } from "./fun_resend_code";
export { auth_funResendCode };