Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
function createUser(err) {
if (err) throw err;
bcrypt.genSalt(10, function(err, salt) {
if (err) throw err;
bcrypt.hash(app_tests.testuser_pass, salt, function() {}, function(err, hash) {
if (err) throw new Error(err);
app_tests.db_users.insert({ // add test user
email: app_tests.testuser_email,
password: hash
}, function(err, user) {
app_tests.testuser = user;
console.log('[DB: testuser added]');
this(err);
}.bind(this));
}.bind(this));
}.bind(this));
},
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);
};
generateHash: (password) => {
/* eslint-disable no-sync */
return bcrypt.hashSync(password, bcrypt.genSaltSync(8), null)
}
},
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 => {
var hash_password = function(plaintext) {
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync(plaintext, salt);
return hash;
};
exports.encryptSync = function(password){
var algo = AppProperties.get("PASSWORD_ENC_ALGO");
if (algo == BCRYPT) {
var bcrypt = require('bcrypt-nodejs');
var salt = bcrypt.genSaltSync(10);
return bcrypt.hashSync(password, salt);
}
else {
return getSHA1Hash(password);
}
};
function hashPassword (instance) {
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync(instance.password, salt);
instance.password = hash;
}
public generateToken() {
const secret = `${this.username}${this.email}${Date.now()}`;
const token = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(4));
const refreshToken = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(2));
this.authToken = new AuthToken(token, refreshToken);
}
public generateToken() {
const secret = `${this.username}${this.email}${Date.now()}`;
const token = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(4));
const refreshToken = Bcrypt.hashSync(secret, Bcrypt.genSaltSync(2));
this.authToken = new AuthToken(token, refreshToken);
}