This commit is contained in:
Timo Knuth
2026-02-27 15:19:24 +01:00
parent b7f8221095
commit 253c3c1c6d
134 changed files with 11188 additions and 1871 deletions

View File

@@ -1,16 +1,22 @@
import { PrismaClient } from '@prisma/client'
import bcrypt from 'bcryptjs'
import { scrypt, randomBytes } from 'crypto'
import { promisify } from 'util'
const scryptAsync = promisify(scrypt)
const prisma = new PrismaClient()
async function hashPassword(password: string): Promise<string> {
const salt = randomBytes(16).toString('hex')
const key = await scryptAsync(password.normalize('NFKC'), salt, 64, {
N: 16384, r: 16, p: 1, maxmem: 128 * 16384 * 16 * 2,
}) as Buffer
return `${salt}:${key.toString('hex')}`
}
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)
console.log('Seeding superadmin...')
const hash = await hashPassword('demo1234')
console.log('Hash generated.')
const superAdminUser = await prisma.user.upsert({
where: { email: 'superadmin@innungsapp.de' },
@@ -25,9 +31,7 @@ async function main() {
await prisma.account.upsert({
where: { id: 'superadmin-account-id' },
update: {
password: hash
},
update: { password: hash },
create: {
id: 'superadmin-account-id',
accountId: superAdminUser.id,
@@ -37,7 +41,7 @@ async function main() {
},
})
console.log('Superadmin updated! Email: superadmin@innungsapp.de, Password: demo1234')
console.log('Done! Login: superadmin@innungsapp.de / demo1234')
}
main()