add password reset

This commit is contained in:
Paul Coral
2025-08-11 23:15:43 +02:00
parent da3a9d6880
commit 1f0a27a2e1
8 changed files with 123 additions and 14 deletions

View File

@@ -1,5 +1,17 @@
import * as crypto from 'crypto';
import * as argon2 from 'argon2';
export function generateSecureToken(length = 32) {
export function generateSecureToken(length = 32): string {
return crypto.randomBytes(length).toString('hex');
}
export function hashPassword(password: string): Promise<string> {
return argon2.hash(password);
}
export function verifyPassword(
passwordHash: string,
clearTextPassword: string,
): Promise<boolean> {
return argon2.verify(passwordHash, clearTextPassword);
}