Files
euchre_camp/scripts/update-admin-password.js
T

52 lines
1.2 KiB
JavaScript

const { PrismaClient } = require('@prisma/client');
const bcrypt = require('bcryptjs');
const prisma = new PrismaClient();
async function main() {
try {
const newPassword = 'adminadmin';
// Find the admin user
const user = await prisma.user.findUnique({
where: { email: 'david@dhg.lol' }
});
if (!user) {
console.log('❌ Admin user not found');
return;
}
// Find the account
const account = await prisma.account.findFirst({
where: { userId: user.id }
});
if (!account) {
console.log('❌ Account not found for user');
return;
}
// Hash new password using bcrypt
const salt = await bcrypt.genSalt(12);
const passwordHash = await bcrypt.hash(newPassword, salt);
// Update the password
await prisma.account.update({
where: { id: account.id },
data: { password: passwordHash }
});
console.log('✅ Admin password updated successfully!');
console.log(' Email:', user.email);
console.log(' New Password:', newPassword);
} catch (error) {
console.error('❌ Error:', error.message);
} finally {
await prisma.$disconnect();
}
}
main();