fix login metode

This commit is contained in:
2025-06-02 17:34:22 +08:00
parent 827b2d10d3
commit b849fead02
2 changed files with 20 additions and 14 deletions

View File

@@ -15,6 +15,20 @@ export async function POST(req: Request) {
const codeOtp = randomOTP();
const body = await req.json();
const { nomor } = body;
const createOtpId = await prisma.kodeOtp.create({
data: {
nomor: nomor,
otp: codeOtp,
},
});
if (!createOtpId)
return NextResponse.json(
{ success: false, message: "Gagal mengirim kode OTP" },
{ status: 400 }
);
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
@@ -30,19 +44,6 @@ export async function POST(req: Request) {
{ status: 400 }
);
const createOtpId = await prisma.kodeOtp.create({
data: {
nomor: nomor,
otp: codeOtp,
},
});
if (!createOtpId)
return NextResponse.json(
{ success: false, message: "Gagal mengirim kode OTP" },
{ status: 400 }
);
return NextResponse.json(
{
success: true,
@@ -54,7 +55,11 @@ export async function POST(req: Request) {
} catch (error) {
backendLogger.log("Error Login", error);
return NextResponse.json(
{ success: false, message: "Terjadi masalah saat login" , reason: error as Error },
{
success: false,
message: "Terjadi masalah saat login",
reason: error as Error,
},
{ status: 500 }
);
} finally {

View File

@@ -39,6 +39,7 @@ export default function Login({ version }: { version: string }) {
router.push("/validasi", { scroll: false });
} else {
setLoading(false);
console.log("respone >>", respone);
ComponentGlobal_NotifikasiPeringatan(respone?.message);
}
} catch (error) {