Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
const isValidPassword = (userpass, password) => {
console.log('isValidPassword', userpass, password);
// hashes the passed-in password and then compares it to the hashed password fetched from the db
return bCrypt.compareSync(password, userpass);
};
const isValidPassword = (userpass, password) => {
// hashes the passed-in password and then compares it to the hashed password fetched from the db
return bCrypt.compareSync(password, userpass);
};
.then(user => {
if ((user.length < 1) || (!bcrypt.compareSync(password, user[0].password))) {
return cb(null, false, { message: config.authentication.messages.login.error });
}
// register user's role for access
acl.addUserRoles(user[0].id.toString(), user[0].role);
return cb(null, user[0].id);
})
.catch(err => {
.then((user) => {
let actualPassword = user.profile.local.password;
return bcrypt.compareSync(password, actualPassword);
});
}
}).then(user => {
if (!user) {
throw new Error(__('login.no_user', null, req.locale))
}
if (!user[name]) {
throw new Error(__('login.no_password', null, req.locale))
}
if (!compareSync(password, user[name].password)) {
throw new Error(__('login.invalid_password', null, req.locale))
}
return user
})
})))