All Tests Work! Password reset implemented. Users list sorted.
This commit is contained in:
34
server/create_admin.cjs
Normal file
34
server/create_admin.cjs
Normal file
@@ -0,0 +1,34 @@
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
(async () => {
|
||||
const prisma = new PrismaClient();
|
||||
try {
|
||||
const email = 'admin@gymflow.com';
|
||||
const password = 'admin123';
|
||||
const hashedPassword = await bcrypt.hash(password, 10);
|
||||
|
||||
const user = await prisma.user.upsert({
|
||||
where: { email },
|
||||
update: {},
|
||||
create: {
|
||||
email,
|
||||
password: hashedPassword,
|
||||
role: 'ADMIN',
|
||||
isFirstLogin: false,
|
||||
profile: {
|
||||
create: {
|
||||
weight: 80,
|
||||
height: 180,
|
||||
gender: 'MALE'
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
console.log('Admin user created/verified:', user);
|
||||
} catch (e) {
|
||||
console.error('Error:', e);
|
||||
} finally {
|
||||
await prisma.$disconnect();
|
||||
}
|
||||
})();
|
||||
Reference in New Issue
Block a user