feat: Set up initial monorepo structure for admin and mobile applications with core configurations and database integration.
This commit is contained in:
BIN
innungsapp/packages/shared/prisma/error.log
Normal file
BIN
innungsapp/packages/shared/prisma/error.log
Normal file
Binary file not shown.
Binary file not shown.
50
innungsapp/packages/shared/prisma/seed-superadmin.ts
Normal file
50
innungsapp/packages/shared/prisma/seed-superadmin.ts
Normal file
@@ -0,0 +1,50 @@
|
||||
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()
|
||||
})
|
||||
14
innungsapp/packages/shared/prisma/test-hash.ts
Normal file
14
innungsapp/packages/shared/prisma/test-hash.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import { auth } from '../apps/admin/lib/auth'
|
||||
|
||||
async function main() {
|
||||
const password = 'demo1234'
|
||||
|
||||
// Actually better-auth 1.x exports a util or hashes internally.
|
||||
// An easy way to fix a user is to just update their password using the auth instance
|
||||
// but since we want to strictly seed the DB, let's just generate it using the bcrypt package directly.
|
||||
|
||||
// For now let's just use the `better-auth` API directly if possible?
|
||||
// Wait, let's look at how better auth handles hashing.
|
||||
}
|
||||
|
||||
main()
|
||||
Reference in New Issue
Block a user