![]() 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/backups/lavocat.quebec/backup-20250730-021618/src/pages/api/admin/ |
import type { NextApiRequest, NextApiResponse } from 'next';
import { getServerSession } from 'next-auth';
import { authOptions } from '@/lib/auth';
import { prisma } from '@/lib/prisma';
import { isEffectiveAdmin } from '@/lib/auth-utils';
export default async function handler(req: NextApiRequest, res: NextApiResponse) {
const session = await getServerSession(req, res, authOptions);
// Check if user is authenticated and is an admin
if (!session || !isEffectiveAdmin(session)) {
return res.status(401).json({ message: 'Unauthorized' });
}
if (req.method === 'POST') {
try {
// Create a test registration
const registration = await prisma.registration.create({
data: {
firstName: 'John',
lastName: 'Doe',
email: 'john@example.com',
phone: '123-456-7890',
birthDate: new Date('1990-01-01'),
relationship: 'Family',
preferredLanguage: 'en',
preferredContactMethod: 'email',
message: 'Test registration',
status: 'PENDING',
address: {
create: {
street: '123 Test St',
city: 'Test City',
state: 'Test State',
postalCode: '12345',
country: 'Test Country'
}
},
detaineeInfo: {
create: {
name: 'Jane Doe',
facility: 'Test Facility',
inmateId: '12345',
incarcerationDate: new Date('2023-01-01'),
expectedReleaseDate: new Date('2024-01-01')
}
}
},
include: {
address: true,
detaineeInfo: true
}
});
return res.status(200).json(registration);
} catch (error) {
console.error('Error creating test registration:', error);
return res.status(500).json({ message: 'Error creating test registration' });
}
}
return res.status(405).json({ message: 'Method not allowed' });
}