36 lines
833 B
JavaScript
36 lines
833 B
JavaScript
const { PrismaClient } = require('@prisma/client');
|
|
const bcrypt = require('bcrypt');
|
|
|
|
const prisma = new PrismaClient();
|
|
|
|
async function main() {
|
|
const username = 'admin';
|
|
const password = 'tegvideo7010!'; // Wähle ein sicheres Passwort
|
|
const hashed = await bcrypt.hash(password, 10);
|
|
|
|
const existing = await prisma.user.findUnique({ where: { username } });
|
|
|
|
if (!existing) {
|
|
const user = await prisma.user.create({
|
|
data: {
|
|
username,
|
|
passwordHash: hashed,
|
|
isAdmin: true,
|
|
expiresAt: null,
|
|
},
|
|
});
|
|
|
|
console.log('✅ Admin-User erstellt:', user.username);
|
|
} else {
|
|
console.log('⚠️ Benutzer existiert bereits.');
|
|
}
|
|
}
|
|
|
|
main()
|
|
.catch((e) => {
|
|
console.error('❌ Fehler beim Seed:', e);
|
|
})
|
|
.finally(async () => {
|
|
await prisma.$disconnect();
|
|
});
|