Admin Passwort in die db und in Backen konfiguriebar
This commit is contained in:
19
prisma/seed.cjs
Normal file
19
prisma/seed.cjs
Normal file
@@ -0,0 +1,19 @@
|
||||
const { PrismaClient } = require('@prisma/client');
|
||||
const bcrypt = require('bcryptjs');
|
||||
|
||||
const prisma = new PrismaClient();
|
||||
|
||||
async function main() {
|
||||
const plainPassword = process.env.ADMIN_PASSWORD || 'admin';
|
||||
const hashed = await bcrypt.hash(plainPassword, 10);
|
||||
|
||||
await prisma.admin.upsert({
|
||||
where: { id: 1 },
|
||||
update: {},
|
||||
create: { id: 1, password: hashed }
|
||||
});
|
||||
|
||||
console.log('✅ Admin erstellt oder aktualisiert');
|
||||
}
|
||||
|
||||
main().finally(() => prisma.$disconnect());
|
||||
Reference in New Issue
Block a user