51 lines
1.3 KiB
TypeScript
51 lines
1.3 KiB
TypeScript
import { PrismaClient } from '@prisma/client'
|
|
import bcrypt from 'bcryptjs'
|
|
|
|
const prisma = new PrismaClient()
|
|
|
|
async function main() {
|
|
console.log('Seeding superadmin with fresh bcryptjs hash...')
|
|
|
|
// Generate hash using bcryptjs, rounds=10
|
|
const salt = bcrypt.genSaltSync(10)
|
|
const hash = bcrypt.hashSync('demo1234', salt)
|
|
|
|
console.log('Generated hash:', hash)
|
|
|
|
const superAdminUser = await prisma.user.upsert({
|
|
where: { email: 'superadmin@innungsapp.de' },
|
|
update: {},
|
|
create: {
|
|
id: 'superadmin-user-id',
|
|
name: 'Super Admin',
|
|
email: 'superadmin@innungsapp.de',
|
|
emailVerified: true,
|
|
},
|
|
})
|
|
|
|
await prisma.account.upsert({
|
|
where: { id: 'superadmin-account-id' },
|
|
update: {
|
|
password: hash
|
|
},
|
|
create: {
|
|
id: 'superadmin-account-id',
|
|
accountId: superAdminUser.id,
|
|
providerId: 'credential',
|
|
userId: superAdminUser.id,
|
|
password: hash,
|
|
},
|
|
})
|
|
|
|
console.log('Superadmin updated! Email: superadmin@innungsapp.de, Password: demo1234')
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error(e)
|
|
process.exit(1)
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect()
|
|
})
|