Skip to content

Commit 8e1a95a

Browse files
committed
added debugging to understand Shaun's issue
1 parent fb4618b commit 8e1a95a

File tree

1 file changed

+23
-1
lines changed
  • app/src/app/api/admin/impersonation-status

1 file changed

+23
-1
lines changed

app/src/app/api/admin/impersonation-status/route.ts

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import {
1111
isAdminUser,
1212
isImpersonationEnabled,
1313
} from "@/lib/auth/adminConfig"
14+
import { prisma } from "@/db/client"
1415

1516
export const dynamic = 'force-dynamic'
1617

@@ -28,8 +29,29 @@ export async function GET() {
2829

2930
const userIsAdmin = await isAdminUser(adminUserId)
3031
if (!userIsAdmin) {
32+
// Debug: fetch user's addresses to see why they're not admin
33+
const user = await prisma.user.findUnique({
34+
where: { id: adminUserId },
35+
include: { addresses: true }
36+
})
37+
38+
const debugInfo = {
39+
userId: adminUserId,
40+
userFound: !!user,
41+
addressCount: user?.addresses?.length || 0,
42+
addresses: user?.addresses?.map(a => a.address) || [],
43+
adminWallets: getAdminWallets(),
44+
impersonationEnabled: isImpersonationEnabled(),
45+
}
46+
47+
console.error("Admin check failed:", debugInfo)
48+
3149
return NextResponse.json(
32-
{ error: "Forbidden", details: "Admin access required" },
50+
{
51+
error: "Forbidden",
52+
details: "Admin access required",
53+
debug: debugInfo
54+
},
3355
{ status: 403 },
3456
)
3557
}

0 commit comments

Comments
 (0)