fix(admin): render users list contract and allowlist user projection

This commit is contained in:
devops committed 2026-10-24 04:45:49 +00:00
1 parent bfb1841370
commit 0dfeab874a
4 files changed
+99 -12

No files matched your search

+22 -7
View File
@@ -168,12 +168,17 @@ export class AdminService {
skip,
take: limit,
orderBy: { [sortField]: sortDirection },
include: {
select: {
id: true,
firstName: true,
lastName: true,
mobile: true,
email: true,
role: true,
walletBalance: true,
charityDonationTotal: true,
createdAt: true,
addresses: true,
walletTransactions: {
orderBy: { createdAt: "desc" },
take: 20,
},
orders: {
where: { status: { not: "CANCELLED" } },
select: { totalAmount: true },
@@ -197,9 +202,19 @@ export class AdminService {
(acc, curr) => acc + (Number(curr.totalAmount) || 0),
0,
) || 0;
const { orders: _orders, ...rest } = u;
// Explicit response allowlist: never expose authentication fields or
// new model columns implicitly through this administrative list.
return {
...rest,
id: u.id,
firstName: u.firstName,
lastName: u.lastName,
mobile: u.mobile,
email: u.email,
role: u.role,
walletBalance: u.walletBalance,
charityDonationTotal: u.charityDonationTotal,
createdAt: u.createdAt,
addresses: u.addresses,
totalSpent,
ordersCount: u._count?.orders || 0,
reviewsCount: (u._count?.reviews || 0) + (u._count?.blogComments || 0),