Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
res.redirect('/');
}
this.dashboard = new Dashboard( this, this.config.signups )
this.waitlist = false;
this.authentication = new Auth( this, this.config.authentication );
if( this.config.signups ){
this.signups( this.config.signups );
this.waitlist = this.config.signups.waitlist;
}
if(this.config.superUser){
var salt = bcrypt.genSaltSync(10),
plainPassword = this.config.superUser.password,
password = bcrypt.hashSync( this.config.superUser.password, salt );
this.config.superUser.password = password;
this.db.createSuperUser( this.config.superUser );
this.config.superUser.password = plainPassword;
}
// critical
this.dashboard.addAuth( this.authentication );
}
UserController.prototype.changePassword = function (userUUID, password) {
Validate.isUUID(userUUID, 'uuid');
Validate.isString(password, 'password');
var self = this;
var pw = Bcrypt.hashSync(password, 10);
self._updateUser(userUUID, { password: pw });
};
}}).then(user => {
const isMatched = bcrypt.hashSync(password, user.password)
if (!isMatched) return done(null, false, { message: "Incorrect password!"})
return done(null, user)
}).catch(err => done(err))
}
encryptPassword: function(password) {
if (!password) return ''
var salt = bcrypt.genSaltSync(10);
var hash = bcrypt.hashSync(password, salt);
return hash;
},
UserSchema.methods.generateHash = function (password) {
return bcrypt.hashSync(password, bcrypt.genSaltSync(saltRounds), null);
};
export function store(req, res) {
const {first_name, last_name, email} = req.body;
const password = bcrypt.hashSync(req.body.password, 10);
User.forge({
first_name, last_name, email, password
}, {hasTimestamps: true}).save()
.then(user => res.json({
success: true,
data: user.toJSON()
})
)
.catch(err => res.status(HttpStatus.INTERNAL_SERVER_ERROR).json({
error: err
})
);
}
exports.hashPassword = password => {
const salt = bcrypt.genSaltSync();
const hash = bcrypt.hashSync(password, salt);
return hash;
};
}
if (!isLength(formData.username, 3, 50)) {
throw new Error(`Bad username length, shoudl be 3-5`);
}
User = await repo.user.findOne({
where: { username: formData.username }
});
if (User) {
throw new Error(`User with username: ${formData.username} already exist`);
}
User = new USER();
User.username = formData.username;
const salt = bcrypt.genSaltSync(5);
User.password = bcrypt.hashSync(formData.password ? formData.password : 'ddd', salt);
if (!_.isArray(User.emails)) {
User.emails = []
}
User.emails.push(Email);
User = await repo.user.save(User);
Email.user = User;
await repo.email.save(Email);
return User;
//#endregion
}
const hashPassword = (password) => {
return bcrypt.hashSync(password, SALT_ROUNDS);
};