This commit is contained in:
32
reset_admin_password.ts
Normal file
32
reset_admin_password.ts
Normal file
@@ -0,0 +1,32 @@
|
||||
|
||||
import { PrismaClient } from '@prisma/client';
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function resetAdmin() {
|
||||
const email = 'admin@digicraft.app';
|
||||
const password = 'adminpassword';
|
||||
const role = 'ADMIN';
|
||||
|
||||
console.log(`Resetting Admin password for: ${email}`);
|
||||
|
||||
const salt = await bcrypt.genSalt(10);
|
||||
const passwordHash = await bcrypt.hash(password, salt);
|
||||
|
||||
try {
|
||||
const user = await prisma.user.upsert({
|
||||
where: { email },
|
||||
update: { passwordHash, role },
|
||||
create: { email, passwordHash, role }
|
||||
});
|
||||
console.log(`✅ SUCCESS! Admin User ${email} is ready.`);
|
||||
console.log(`🔑 Password: ${password}`);
|
||||
} catch (e) {
|
||||
console.error("❌ Error upserting admin:", e);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
}
|
||||
|
||||
resetAdmin();
|
||||
Reference in New Issue
Block a user