Admin Passwort in die db und in Backen konfiguriebar

This commit is contained in:
titver968
2025-04-17 16:00:18 +02:00
parent 06693cf59a
commit b3c7113ce4
11 changed files with 366 additions and 16 deletions

View File

@@ -0,0 +1,5 @@
-- CreateTable
CREATE TABLE "Admin" (
"id" INTEGER NOT NULL PRIMARY KEY AUTOINCREMENT DEFAULT 1,
"password" TEXT NOT NULL
);

Binary file not shown.

View File

@@ -8,6 +8,11 @@ datasource db {
url = "file:./praktika.db"
}
model Admin {
id Int @id @default(1)
password String
}
model Dienststelle {
id Int @id @default(autoincrement())
name String @unique

19
prisma/seed.cjs Normal file
View 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());