feat: Version 1.10.0 — DB-Zugriff auf PHP-Bridge (DB4js_all.php) umgestellt
- lib/db.ts entfernt, mysql2-Abhängigkeit gestrichen - lib/phpdb.ts: HTTP-Client für alle DB-Operationen via DB4js_all.php - Alle API-Routen und Server Actions auf phpdb.ts umgestellt - compose.yml / docker-compose.prod.yml: MySQL/phpMyAdmin-Container entfernt - app/api/DB4js_all.php/route.ts: Proxy für Statistik-AJAX-Calls - Statistik-Grafik liest ab 2026 live aus logbuch statt StatistikJahre - PHP 7.3-Kompatibilität: str_contains → strpos Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+5
-27
@@ -1,34 +1,13 @@
|
||||
import bcrypt from 'bcryptjs';
|
||||
import { query } from './db';
|
||||
import { getBeoByKuerzel, getBeoByName } from './phpdb';
|
||||
|
||||
export interface Beo {
|
||||
id: number;
|
||||
name: string;
|
||||
vorname: string | null;
|
||||
kürzel: string | null;
|
||||
pw: string | null;
|
||||
MustChangePassword: number;
|
||||
role: string | null;
|
||||
}
|
||||
|
||||
export async function getBeoByKuerzel(kuerzel: string): Promise<Beo | null> {
|
||||
const rows = await query(
|
||||
'SELECT id, name, vorname, `kürzel`, pw, MustChangePassword, role FROM beos WHERE `kürzel` = ?',
|
||||
[kuerzel]
|
||||
) as Beo[];
|
||||
return rows[0] ?? null;
|
||||
}
|
||||
export type { Beo } from './phpdb';
|
||||
import type { Beo } from './phpdb';
|
||||
|
||||
export async function getBeoByLogin(login: string): Promise<Beo | null> {
|
||||
// First try exact Kürzel match, then case-insensitive Nachname match
|
||||
const byKuerzel = await getBeoByKuerzel(login);
|
||||
if (byKuerzel) return byKuerzel;
|
||||
|
||||
const rows = await query(
|
||||
'SELECT id, name, vorname, `kürzel`, pw, MustChangePassword, role FROM beos WHERE LOWER(name) = LOWER(?)',
|
||||
[login]
|
||||
) as Beo[];
|
||||
return rows[0] ?? null;
|
||||
return getBeoByName(login);
|
||||
}
|
||||
|
||||
export async function verifyCredentials(
|
||||
@@ -41,8 +20,7 @@ export async function verifyCredentials(
|
||||
if (!beo.pw) {
|
||||
const defaultPw = process.env.DEFAULT_PASSWORD;
|
||||
if (!defaultPw) throw new Error('DEFAULT_PASSWORD Umgebungsvariable ist nicht gesetzt!');
|
||||
const valid = password === defaultPw;
|
||||
return { beo, valid };
|
||||
return { beo, valid: password === defaultPw };
|
||||
}
|
||||
|
||||
const valid = await bcrypt.compare(password, beo.pw);
|
||||
|
||||
Reference in New Issue
Block a user