Initial commit: Kalendartool (Next.js, Prisma, Docker)

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This commit is contained in:
Kühn
2026-10-08 14:38:04 +02:00
commit bc49c3074e
94 changed files with 12812 additions and 0 deletions

21
lib/auth/password.ts Normal file
View File

@@ -0,0 +1,21 @@
/**
* Passwort-Hashing mit bcrypt (plan.md Abschnitt 11:
* "Passwoerter niemals selbst verschluesseln oder im Klartext speichern").
*/
import bcrypt from 'bcryptjs';
/** Kostenfaktor: 12 Runden sind aktueller Standard (ca. 200-300 ms). */
const BCRYPT_ROUNDS = 12;
/** Hasht ein Klartext-Passwort fuer die Speicherung in der Datenbank. */
export async function hashPassword(plainPassword: string): Promise<string> {
return bcrypt.hash(plainPassword, BCRYPT_ROUNDS);
}
/** Prueft ein Klartext-Passwort gegen den gespeicherten Hash. */
export async function verifyPassword(
plainPassword: string,
passwordHash: string,
): Promise<boolean> {
return bcrypt.compare(plainPassword, passwordHash);
}