Initial implementation: Logbuch Sternwarte Welzheim

Vollständige Next.js 16 Webanwendung als Logbuch für die Sternwarte Welzheim.
4 Kuppeln (West/Ost/Süd/Pluto), BEO-basierte Authentifizierung mit erzwungenem
Passwort-Wechsel beim Erstlogin, MySQL-Backend, Docker-Deployment.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-27 17:11:27 +02:00
parent f0a86627e5
commit 4e53a7a5cd
29 changed files with 1827 additions and 97 deletions

38
lib/auth.ts Normal file
View File

@@ -0,0 +1,38 @@
import bcrypt from 'bcryptjs';
import { query } from './db';
export interface Beo {
ID: number;
Kuerzel: string;
Name: string;
Passwort: string | null;
MustChangePassword: number;
}
export async function getBeoByKuerzel(kuerzel: string): Promise<Beo | null> {
const rows = await query(
'SELECT ID, Kuerzel, Name, Passwort, MustChangePassword FROM beos WHERE Kuerzel = ?',
[kuerzel]
) as Beo[];
return rows[0] ?? null;
}
export async function verifyCredentials(
kuerzel: string,
password: string
): Promise<{ beo: Beo; valid: boolean } | null> {
const beo = await getBeoByKuerzel(kuerzel);
if (!beo) return null;
if (!beo.Passwort) {
const valid = password === 'logbuch123';
return { beo, valid };
}
const valid = await bcrypt.compare(password, beo.Passwort);
return { beo, valid };
}
export async function hashPassword(password: string): Promise<string> {
return bcrypt.hash(password, 10);
}