project setup with core files including configuration, package management, and basic structure. Added .gitignore, README, and various TypeScript types for CMS components. Implemented initial components and layouts for the application.
This commit is contained in:
31
middlelayer/auth/password.ts
Normal file
31
middlelayer/auth/password.ts
Normal file
@@ -0,0 +1,31 @@
|
||||
import bcrypt from "bcryptjs";
|
||||
import { logger } from "../monitoring/logger.js";
|
||||
|
||||
const SALT_ROUNDS = 10;
|
||||
|
||||
/**
|
||||
* Hasht ein Passwort
|
||||
*/
|
||||
export async function hashPassword(password: string): Promise<string> {
|
||||
try {
|
||||
return await bcrypt.hash(password, SALT_ROUNDS);
|
||||
} catch (error) {
|
||||
logger.error("Password hashing failed", { error });
|
||||
throw new Error("Fehler beim Hashen des Passworts");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Vergleicht ein Passwort mit einem Hash
|
||||
*/
|
||||
export async function comparePassword(
|
||||
password: string,
|
||||
hash: string
|
||||
): Promise<boolean> {
|
||||
try {
|
||||
return await bcrypt.compare(password, hash);
|
||||
} catch (error) {
|
||||
logger.error("Password comparison failed", { error });
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user