Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
if (requirePassword) {
if (!password) {
throw new InvalidRequestError('Password required');
}
const user = await this.accountDB.getByName(name);
if (!user) {
throw new InvalidRequestError('User does not exist');
}
// For legacy reasons, the password was truncated to 100 chars.
password = password.substring(0, 100);
if (!await bcrypt.compareAsync(password, user.password)) {
throw new InvalidRequestError('Invalid password');
}
}
await this.accountDB.updateByName(name, fields);
}
}
function check_password(password, hashed_password)
{
return bcrypt.compareAsync(password, hashed_password)
}
function check_password(password, hashed_password)
{
return bcrypt.compareAsync(password, hashed_password)
}
User.prototype.validPassword = function (pwd) {
return bcrypt.compareAsync(pwd, this.password)
.then(function (isMatch) {
return isMatch;
});
};
static comparePassword(password, hashedPassword) {
password = this.getPasswordString(password);
return bcrypt.compareAsync(password, hashedPassword);
}
}