V 1.2.2 Login-Seite: bcrypt-Passwörter, Passwort-Toggle, Footer
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
+6
-8
@@ -1,8 +1,4 @@
|
||||
/**
|
||||
* Authentifizierungsbibliothek
|
||||
* Benutzer via Umgebungsvariable konfigurieren:
|
||||
* AUTH_USERS=user1:passwort1,user2:passwort2
|
||||
*/
|
||||
import bcrypt from 'bcryptjs';
|
||||
|
||||
export interface User {
|
||||
username: string;
|
||||
@@ -24,11 +20,13 @@ export function getUsers(): User[] {
|
||||
.filter((user) => user.username && user.password);
|
||||
}
|
||||
|
||||
export function verifyCredentials(username: string, password: string): boolean {
|
||||
export async function verifyCredentials(username: string, password: string): Promise<boolean> {
|
||||
const users = getUsers();
|
||||
const user = users.find(u => u.username === username);
|
||||
if (!user) return false;
|
||||
return user.password === password;
|
||||
if (!user) {
|
||||
return false;
|
||||
}
|
||||
return bcrypt.compare(password, user.password);
|
||||
}
|
||||
|
||||
export function isAuthEnabled(): boolean {
|
||||
|
||||
Reference in New Issue
Block a user