fix login metode
This commit is contained in:
@@ -15,6 +15,20 @@ export async function POST(req: Request) {
|
|||||||
const codeOtp = randomOTP();
|
const codeOtp = randomOTP();
|
||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
const { nomor } = body;
|
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(
|
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.
|
`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
|
\n
|
||||||
@@ -30,19 +44,6 @@ export async function POST(req: Request) {
|
|||||||
{ status: 400 }
|
{ 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(
|
return NextResponse.json(
|
||||||
{
|
{
|
||||||
success: true,
|
success: true,
|
||||||
@@ -54,7 +55,11 @@ export async function POST(req: Request) {
|
|||||||
} catch (error) {
|
} catch (error) {
|
||||||
backendLogger.log("Error Login", error);
|
backendLogger.log("Error Login", error);
|
||||||
return NextResponse.json(
|
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 }
|
{ status: 500 }
|
||||||
);
|
);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -39,6 +39,7 @@ export default function Login({ version }: { version: string }) {
|
|||||||
router.push("/validasi", { scroll: false });
|
router.push("/validasi", { scroll: false });
|
||||||
} else {
|
} else {
|
||||||
setLoading(false);
|
setLoading(false);
|
||||||
|
console.log("respone >>", respone);
|
||||||
ComponentGlobal_NotifikasiPeringatan(respone?.message);
|
ComponentGlobal_NotifikasiPeringatan(respone?.message);
|
||||||
}
|
}
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
|
|||||||
Reference in New Issue
Block a user