Automatic creation of Admin user (TEST)

This commit is contained in:
rudi committed 2026-07-30 11:57:35 +02:00
1 parent 4ccd860814
commit d395308c6d
2 files changed
+13 -37

No files matched your search

+13 -17
View File
@@ -2,21 +2,17 @@ import { prisma } from "@/lib/db/prisma"
import argon2 from 'argon2'
export async function initDB() {
// const count = await prisma.user.count()
//
// if (count === 0) {
// await prisma.user.create({
// data: {
// email: process.env.ADMIN_EMAIL!,
// username: 'admin',
// password: await argon2.hash(process.env.ADMIN_PASSWORD!),
// role: 'admin',
// firstname: 'Admin'
// }
// })
// console.log('Admin-User angelegt.')
// }
console.log("Start der DB");
const count = await prisma.user.count();
console.log(count);
const count = await prisma.user.count()
if (count === 0) {
await prisma.user.create({
data: {
username: process.env.ADMIN_USERNAME!,
password: await argon2.hash(process.env.ADMIN_PASSWORD!),
role: 'admin',
name: 'Admin'
}
})
console.log('Admin-User angelegt.')
}
}