29 lines
857 B
TypeScript
29 lines
857 B
TypeScript
// /opt/erp-system/app/api/setup-customer/route.ts
|
|
import { NextResponse } from 'next/server';
|
|
import prisma from '../../../lib/prisma';
|
|
import bcrypt from 'bcryptjs';
|
|
|
|
export async function GET() {
|
|
try {
|
|
const customer = await prisma.customer.findFirst({ orderBy: { id: 'asc' } });
|
|
|
|
if (!customer) {
|
|
return NextResponse.json({ error: 'Kein Kunde im System gefunden.' }, { status: 404 });
|
|
}
|
|
|
|
const hash = await bcrypt.hash('portal123', 10);
|
|
|
|
await prisma.customer.update({
|
|
where: { id: customer.id },
|
|
data: { passwordHash: hash }
|
|
});
|
|
|
|
return NextResponse.json({
|
|
success: true,
|
|
message: `Passwort für Kunde ${customer.email} (ID: ${customer.id}) erfolgreich auf 'portal123' gesetzt.`
|
|
});
|
|
} catch (error) {
|
|
return NextResponse.json({ error: 'Fehler' }, { status: 500 });
|
|
}
|
|
}
|