How to use the bcrypt.hashSync function in bcrypt

To help you get started, we’ve selected a few bcrypt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github liamks / Drawbridge.js / lib / drawbridge.js View on Github external
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 );
  

}
github PufferPanel / PufferPanel / lib / controller / user.js View on Github external
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 });
};
github mthais / resumeweb / server / controller / user.js View on Github external
}}).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))
}
github rgallagher27 / node-restify-oauth2-mongodb / Models / user.js View on Github external
encryptPassword: function(password) {
      if (!password) return ''

      var salt = bcrypt.genSaltSync(10);
      var hash = bcrypt.hashSync(password, salt);

      return hash;
   },
github aniketnk / alcoding-web-portal / server / models / User.js View on Github external
UserSchema.methods.generateHash = function (password) {
  return bcrypt.hashSync(password, bcrypt.genSaltSync(saltRounds), null);
};
github Bikranshu / express-react-boilerplate / server / controllers / user.controller.js View on Github external
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
            })
        );
}
github themostaza / koa-starter / src / utils / crypto.js View on Github external
exports.hashPassword = password => {
  const salt = bcrypt.genSaltSync();
  const hash = bcrypt.hashSync(password, salt);
  return hash;
};
github darekf77 / morphi / projects / examples / isomorphic-lib / src / controllers / AuthController.ts View on Github external
}
    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
  }
github maritz / nohm / examples / rest-user-server / UserModel.js View on Github external
const hashPassword = (password) => {
  return bcrypt.hashSync(password, SALT_ROUNDS);
};