T.ME/BIBIL_0DAY
CasperSecurity


Server : Apache/2
System : Linux server-15-235-50-60 5.15.0-164-generic #174-Ubuntu SMP Fri Nov 14 20:25:16 UTC 2025 x86_64
User : gositeme ( 1004)
PHP Version : 8.2.29
Disable Function : exec,system,passthru,shell_exec,proc_close,proc_open,dl,popen,show_source,posix_kill,posix_mkfifo,posix_getpwuid,posix_setpgid,posix_setsid,posix_setuid,posix_setgid,posix_seteuid,posix_setegid,posix_uname
Directory :  /home/gositeme/domains/lavocat.quebec/private_html/scripts/

Upload File :
current_dir [ Writeable ] document_root [ Writeable ]

 

Current File : /home/gositeme/domains/lavocat.quebec/private_html/scripts/test-superadmin-registrations.js
const { PrismaClient } = require('@prisma/client');

const prisma = new PrismaClient();

async function testSuperadminRegistrations() {
  try {
    console.log('šŸ” Testing SUPERADMIN registrations access...\n');

    // Get the SUPERADMIN user
    const superadmin = await prisma.user.findFirst({
      where: { role: 'SUPERADMIN' }
    });

    if (!superadmin) {
      console.log('āŒ No SUPERADMIN user found');
      return;
    }

    console.log(`šŸ‘‘ SUPERADMIN found: ${superadmin.name} (${superadmin.email}) - ID: ${superadmin.id}\n`);

    // Test the same query logic as the user registrations API
    const registrations = await prisma.registration.findMany({
      where: {
        OR: [
          { userId: superadmin.id },
          { 
            AND: [
              { userId: null },
              { email: superadmin.email }
            ]
          },
          { 
            AND: [
              { createdBy: { not: null } },
              { createdBy: superadmin.id }
            ]
          }
        ]
      },
      orderBy: {
        createdAt: 'desc',
      },
      include: {
        detaineeInfo: true,
        address: true,
        legalCase: {
          select: {
            id: true,
            title: true,
            caseNumber: true,
            status: true,
            leadLawyer: {
              select: {
                name: true,
                email: true
              }
            }
          }
        },
        creator: {
          select: {
            id: true,
            email: true,
            name: true
          }
        },
        user: {
          select: {
            id: true,
            email: true,
            name: true
          }
        }
      },
    });

    console.log(`šŸ“Š Found ${registrations.length} registrations for SUPERADMIN\n`);

    if (registrations.length > 0) {
      console.log('šŸ“‹ Registrations found:');
      registrations.forEach((reg, index) => {
        console.log(`\n${index + 1}. Registration ID: ${reg.id}`);
        console.log(`   Name: ${reg.firstName} ${reg.lastName}`);
        console.log(`   Email: ${reg.email}`);
        console.log(`   Status: ${reg.status}`);
        console.log(`   userId: ${reg.userId}`);
        console.log(`   createdBy: ${reg.createdBy}`);
        console.log(`   Created: ${reg.createdAt}`);
        console.log(`   Updated: ${reg.updatedAt}`);
        
        if (reg.detaineeInfo) {
          console.log(`   Detainee: ${reg.detaineeInfo.name} (${reg.detaineeInfo.facility})`);
        }
        
        if (reg.legalCase) {
          console.log(`   Case: ${reg.legalCase.title} (${reg.legalCase.caseNumber})`);
        }
        
        if (reg.documents && reg.documents.length > 0) {
          console.log(`   Documents: ${reg.documents.length} uploaded`);
        }
      });
    } else {
      console.log('āŒ No registrations found for SUPERADMIN');
      
      // Check if there are any registrations at all
      const allRegistrations = await prisma.registration.findMany();
      console.log(`\nšŸ“Š Total registrations in database: ${allRegistrations.length}`);
      
      if (allRegistrations.length > 0) {
        console.log('\nšŸ“‹ All registrations:');
        allRegistrations.forEach(reg => {
          console.log(`  - ${reg.id}: ${reg.firstName} ${reg.lastName} (${reg.email})`);
          console.log(`    userId: ${reg.userId}, createdBy: ${reg.createdBy}, status: ${reg.status}`);
        });
      }
    }

  } catch (error) {
    console.error('āŒ Error:', error);
  } finally {
    await prisma.$disconnect();
  }
}

testSuperadminRegistrations(); 

CasperSecurity Mini