mirror of
http://172.20.10.11:3000/gitadmin/INSIGHT-MVP.git
synced 2026-06-24 23:56:40 +02:00
Switch from hostname+HTTPS (insight-dev.xinion.lan) to IP+HTTP (172.20.10.59) for alpha/dev deployment without DNS. Key changes: - Cookie secure/sameSite flags environment-conditional (fixes HTTP auth) - docker-compose.yml: remove HTTPS, update host rules, reduce PG memory - Traefik: disable TLS, update CORS/CSP for HTTP - Add Prisma init migration (7 tables) and admin seed script - Generate package-lock.json for npm ci in Docker builds - Update all documentation for IP-based access Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
65 lines
1.6 KiB
TypeScript
65 lines
1.6 KiB
TypeScript
import { PrismaClient } from '@prisma/client';
|
|
import * as bcrypt from 'bcrypt';
|
|
|
|
/**
|
|
* Seed-Script: Erstellt den initialen Platform-Admin User.
|
|
*
|
|
* Ausfuehrung:
|
|
* npx ts-node prisma/seed.ts
|
|
*
|
|
* WICHTIG: Passwort nach erstem Login aendern!
|
|
*/
|
|
|
|
const prisma = new PrismaClient({
|
|
datasources: {
|
|
db: {
|
|
url: process.env.DATABASE_URL_DIRECT || process.env.DATABASE_URL,
|
|
},
|
|
},
|
|
});
|
|
|
|
async function main(): Promise<void> {
|
|
const email = 'admin@xinion.de';
|
|
|
|
// Pruefen ob Admin bereits existiert
|
|
const existing = await prisma.user.findUnique({ where: { email } });
|
|
if (existing) {
|
|
console.log(`Admin-User ${email} existiert bereits. Seed uebersprungen.`);
|
|
return;
|
|
}
|
|
|
|
// Passwort hashen (Bcrypt Cost 12 gemaess Sicherheitsregel)
|
|
const passwordHash = await bcrypt.hash('ChangeMe123!', 12);
|
|
|
|
// Admin-User anlegen
|
|
const user = await prisma.user.create({
|
|
data: {
|
|
email,
|
|
firstName: 'Platform',
|
|
lastName: 'Admin',
|
|
role: 'PLATFORM_ADMIN',
|
|
isActive: true,
|
|
authProvider: {
|
|
create: {
|
|
provider: 'LOCAL',
|
|
passwordHash,
|
|
},
|
|
},
|
|
},
|
|
});
|
|
|
|
console.log(`Platform-Admin erstellt: ${user.email} (ID: ${user.id})`);
|
|
console.log('');
|
|
console.log('Zugangsdaten:');
|
|
console.log(` E-Mail: ${email}`);
|
|
console.log(' Passwort: ChangeMe123!');
|
|
console.log('');
|
|
console.log('WICHTIG: Passwort nach erstem Login aendern!');
|
|
}
|
|
|
|
main()
|
|
.catch((e: Error) => {
|
|
console.error('Seed fehlgeschlagen:', e.message);
|
|
process.exit(1);
|
|
})
|
|
.finally(() => prisma.$disconnect());
|