nextjs-rewrite (#5)
Reviewed-on: #5 Co-authored-by: David Gwilliam <dhgwilliam@gmail.com> Co-committed-by: David Gwilliam <dhgwilliam@gmail.com>
This commit was merged in pull request #5.
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
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();
|
||||
Reference in New Issue
Block a user