merge: integrate Alexis latest changes
This commit is contained in:
39
backend/src/scripts/createAdmin.js
Normal file
39
backend/src/scripts/createAdmin.js
Normal file
@@ -0,0 +1,39 @@
|
||||
const bcrypt = require('bcrypt')
|
||||
const prisma = require('../config/prisma')
|
||||
|
||||
async function createAdmin() {
|
||||
const email = 'admin@thetiptop.fr'
|
||||
const password = 'Admin@TipTop2026!'
|
||||
|
||||
const existing = await prisma.user.findUnique({ where: { email } })
|
||||
|
||||
if (existing) {
|
||||
await prisma.user.update({
|
||||
where: { email },
|
||||
data: { isEmailVerified: true, role: 'ADMIN' },
|
||||
})
|
||||
console.log('Admin mis à jour :', email)
|
||||
return
|
||||
}
|
||||
|
||||
const hashed = await bcrypt.hash(password, 10)
|
||||
|
||||
await prisma.user.create({
|
||||
data: {
|
||||
firstname: 'Admin',
|
||||
lastname: 'TipTop',
|
||||
email,
|
||||
password: hashed,
|
||||
role: 'ADMIN',
|
||||
isEmailVerified: true,
|
||||
},
|
||||
})
|
||||
|
||||
console.log('Admin créé avec succès')
|
||||
console.log(' Email :', email)
|
||||
console.log(' Mot de passe:', password)
|
||||
}
|
||||
|
||||
createAdmin()
|
||||
.catch((e) => { console.error('Erreur :', e.message); process.exit(1) })
|
||||
.finally(() => prisma.$disconnect())
|
||||
Reference in New Issue
Block a user