File tree Expand file tree Collapse file tree 1 file changed +23
-1
lines changed
app/src/app/api/admin/impersonation-status Expand file tree Collapse file tree 1 file changed +23
-1
lines changed Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ import {
1111 isAdminUser ,
1212 isImpersonationEnabled ,
1313} from "@/lib/auth/adminConfig"
14+ import { prisma } from "@/db/client"
1415
1516export 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 }
You can’t perform that action at this time.
0 commit comments