Fix route untuk penambahan fitur EULA
Fix: - modified: src/app/api/auth/mobile-login/route.ts Add: - src/app/api/auth/mobile-eula/ ### No Issue
This commit is contained in:
54
src/app/api/auth/mobile-eula/route.tsx
Normal file
54
src/app/api/auth/mobile-eula/route.tsx
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
import { prisma } from "@/lib";
|
||||||
|
import { NextResponse } from "next/server";
|
||||||
|
|
||||||
|
export async function POST(req: Request) {
|
||||||
|
try {
|
||||||
|
const { nomor } = await req.json();
|
||||||
|
|
||||||
|
const user = await prisma.user.findUnique({
|
||||||
|
where: {
|
||||||
|
nomor: nomor,
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!user)
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "User belum terdaftar",
|
||||||
|
status: 404,
|
||||||
|
});
|
||||||
|
|
||||||
|
const updateTerms = await prisma.user.update({
|
||||||
|
where: { nomor: nomor },
|
||||||
|
data: {
|
||||||
|
termsOfServiceAccepted: true,
|
||||||
|
acceptedTermsAt: new Date(),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
|
||||||
|
if (!updateTerms) {
|
||||||
|
return NextResponse.json({
|
||||||
|
success: false,
|
||||||
|
message: "Gagal setujui syarat dan ketentuan",
|
||||||
|
status: 400,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: true,
|
||||||
|
message: "Anda telah setujui syarat dan ketentuan",
|
||||||
|
},
|
||||||
|
{ status: 200 }
|
||||||
|
);
|
||||||
|
} catch (error) {
|
||||||
|
return NextResponse.json(
|
||||||
|
{
|
||||||
|
success: false,
|
||||||
|
message: "Terjadi masalah saat setujui syarat dan ketentuan",
|
||||||
|
reason: error as Error,
|
||||||
|
},
|
||||||
|
{ status: 500 }
|
||||||
|
);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -6,7 +6,6 @@ export async function POST(req: Request) {
|
|||||||
try {
|
try {
|
||||||
const codeOtp = randomOTP();
|
const codeOtp = randomOTP();
|
||||||
const body = await req.json();
|
const body = await req.json();
|
||||||
console.log("[Masuk API]", body);
|
|
||||||
const { nomor } = body;
|
const { nomor } = body;
|
||||||
|
|
||||||
const user = await prisma.user.findUnique({
|
const user = await prisma.user.findUnique({
|
||||||
@@ -15,9 +14,6 @@ export async function POST(req: Request) {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
console.log(["cek user", user]);
|
|
||||||
console.log(["cek nomor", nomor]);
|
|
||||||
|
|
||||||
if (!user)
|
if (!user)
|
||||||
return NextResponse.json({
|
return NextResponse.json({
|
||||||
success: false,
|
success: false,
|
||||||
@@ -66,6 +62,7 @@ export async function POST(req: Request) {
|
|||||||
success: true,
|
success: true,
|
||||||
message: "Kode verifikasi terkirim",
|
message: "Kode verifikasi terkirim",
|
||||||
kodeId: createOtpId.id,
|
kodeId: createOtpId.id,
|
||||||
|
isAcceptTerms: user.termsOfServiceAccepted,
|
||||||
},
|
},
|
||||||
{ status: 200 }
|
{ status: 200 }
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user