Skip to main content

passwordHandler

function passwordHandler(password: string, hashedPassword: string)
async

Compares a plaintext password with a hashed password.

Returns: Promise<boolean>

  • true if passwords match, otherwise false.
    See the official bcrypt package documentation for more details:
PARAMETERTYPEOPTIONALDEFAULTDESCRIPTION
passwordstringThe plaintext password.
hashedPasswordstringThe hashed password for comparison.

See:

const isMatch = await passwordHandler("myPassword", storedHashedPassword);
if (isMatch) {
console.log("Password is correct");
}