Passwords.checkPassword()

Compare a plaintext password attempt against an already-encrypted version.

Useful for checking a password attempt against the stored, already-encrypted BCrypt hash.

Usage

Hover over inputs/exits for more info.

var Passwords = require('machinepack-passwords');


// Compare a plaintext password attempt against an already-encrypted version.

Passwords.checkPassword({

passwordAttempt: 'l0lcatzz',

encryptedPassword: 'as34hafsu#w34ndcarok',

}).exec({

// An unexpected error occurred.

error: function (err) {

 

},

// Password attempt does not match already-encrypted version

incorrect: function () {

 

},

// OK.

success: function () {

 

},

});

Inputs

passwordAttempt required

The password attempt (unencrypted).

'l0lcatzz'
encryptedPassword required

The existing (already-encrypted) password hash to compare against.

'as34hafsu#w34ndcarok'

Exits

error

An unexpected error occurred.

incorrect

Password attempt does not match already-encrypted version

success

OK.