Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions actions/user.ts
Original file line number Diff line number Diff line change
Expand Up @@ -368,8 +368,12 @@ export async function updateUserKycStatus(
user.isKycVerified = false
user.kycVerified = false
} else if (physicalMeetingStatus === "approved") {
if (oldPhysicalMeetingStatus !== "scheduled") {
return { success: false, message: "Only scheduled meetings can be approved." }
if (
oldPhysicalMeetingStatus !== "scheduled" &&
oldPhysicalMeetingStatus !== "none" &&
oldPhysicalMeetingStatus !== "rescheduled"
) {
return { success: false, message: "Only scheduled, none, or rescheduled meetings can be approved." }
}

if (!user.physicalMeetingDate && !normalizedMeetingDate) {
Expand Down
37 changes: 37 additions & 0 deletions app/api/admin/kyc-requests/[id]/audit/route.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
import { NextResponse } from "next/server"

import { finalizeAuthenticatedResponse, requireAuthenticatedUser } from "@/lib/api/route-guard"
import dbConnect from "@/lib/dbConnect"
import AuditLog from "@/models/AuditLog"

interface RouteContext {
params: Promise<{ id: string }>
}

export async function GET(request: Request, context: RouteContext) {
try {
await dbConnect()

const authContext = await requireAuthenticatedUser(request, ["admin"], {
forbiddenMessage: "Admin access required",
})
if ("response" in authContext) return authContext.response

const { id } = await context.params
if (!id) {
return NextResponse.json({ error: "User ID is required" }, { status: 400 })
}

// Retrieve all audit logs related to this user target ID
const auditLogs = await AuditLog.find({ targetId: id })
.sort({ createdAt: -1 })
.limit(100)
.lean()

const response = NextResponse.json(auditLogs, { status: 200 })
return finalizeAuthenticatedResponse(response, authContext)
} catch (error) {
console.error("KYC_USER_AUDIT_LOG_GET_ERROR", error)
return NextResponse.json({ error: "Internal server error" }, { status: 500 })
}
}
Loading