![]() 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/ |
const { PrismaClient } = require('@prisma/client');
const bcrypt = require('bcryptjs');
const prisma = new PrismaClient();
async function resetSuperAdminPassword() {
try {
console.log('š Resetting SUPERADMIN password...');
// Find the user by email, regardless of role
const superAdmin = await prisma.user.findFirst({
where: {
email: 'dannywperez@msn.com',
},
select: {
id: true,
name: true,
email: true,
role: true
}
});
if (!superAdmin) {
console.log('ā SUPERADMIN user not found. Creating one...');
const hashedPassword = await bcrypt.hash('demo123', 12);
const newSuperAdmin = await prisma.user.create({
data: {
email: 'dannywperez@msn.com',
name: 'Danny PEREZ',
password: hashedPassword,
role: 'SUPERADMIN',
notifications: true,
theme: 'light',
isActive: true
}
});
console.log('ā
Created new SUPERADMIN user:');
console.log(` š¤ Name: ${newSuperAdmin.name}`);
console.log(` š§ Email: ${newSuperAdmin.email}`);
console.log(` š Password: demo123`);
console.log(` š Role: ${newSuperAdmin.role}`);
} else {
// Update password and role
const hashedPassword = await bcrypt.hash('demo123', 12);
await prisma.user.update({
where: { id: superAdmin.id },
data: {
password: hashedPassword,
role: 'SUPERADMIN',
isActive: true
}
});
console.log('ā
Password and role reset successfully!');
console.log(` š§ Email: dannywperez@msn.com`);
console.log(` š New password: demo123`);
console.log(` š Role: SUPERADMIN`);
}
// Verify the password works
console.log('\nš Verifying password reset...');
const testUser = await prisma.user.findUnique({
where: {
email: 'dannywperez@msn.com'
},
select: {
id: true,
email: true,
password: true,
role: true,
name: true
}
});
if (testUser) {
const isValid = await bcrypt.compare('demo123', testUser.password);
if (isValid) {
console.log('ā
Password verification successful!');
console.log('š You can now log in with:');
console.log(` š§ Email: dannywperez@msn.com`);
console.log(` š Password: demo123`);
} else {
console.log('ā Password verification failed!');
}
}
// Show all available login accounts
console.log('\nš All Available Demo Accounts:');
console.log('=' .repeat(50));
const allUsers = await prisma.user.findMany({
select: {
name: true,
email: true,
role: true
},
orderBy: {
role: 'desc'
}
});
allUsers.forEach(user => {
const roleInfo = getRoleInfo(user.role);
console.log(`${roleInfo.icon} ${user.name} (${user.email})`);
console.log(` Role: ${roleInfo.label} | Password: demo123`);
console.log('');
});
console.log('šÆ Quick Login URLs:');
console.log(' š HTTPS: https://localhost:3443/auth/login');
console.log(' š HTTP: http://localhost:3000/auth/login');
} catch (error) {
console.error('ā Error resetting SUPERADMIN password:', error);
} finally {
await prisma.$disconnect();
}
}
function getRoleInfo(role) {
switch (role) {
case 'SUPERADMIN':
case 'SUPERADMIN':
case 'SUPERADMIN':
return { label: 'Super Admin', icon: 'š' };
case 'ADMIN':
return { label: 'Admin', icon: 'š©āāļø' };
case 'LAWYER':
return { label: 'Lawyer', icon: 'āļø' };
case 'SECRETARY':
return { label: 'Secretary', icon: 'š' };
case 'ASSISTANT':
return { label: 'Assistant', icon: 'š¤' };
case 'CLERK':
return { label: 'Law Clerk', icon: 'š' };
case 'CLIENT':
return { label: 'Client', icon: 'š¤' };
default:
return { label: role, icon: 'š¤' };
}
}
// Run the script
resetSuperAdminPassword();