add password reset
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user