How to use the bcryptjs.getSalt function in bcryptjs

To help you get started, we’ve selected a few bcryptjs 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 PacktPublishing / Building-Enterprise-JavaScript-Applications / Chapter09 / hobnob / src / engines / auth / get-salt / index.js View on Github external
function getSalt (req) {
  return client.search({
    index: process.env.ELASTICSEARCH_INDEX,
    type: 'user',
    body: {
      query: {
        match: {
          email: req.body.email
        }
      }
    },
    _sourceInclude: 'digest'
  })
  .then(extractDigest)
  .then(bcrypt.getSalt)
  .catch(err => {
    if (err.message === NO_RESULTS_ERROR_MESSAGE) {
      return generateFakeSalt(req.body.email);
    }
    return Promise.reject(new Error('Internal Server Error'));
  });
}

bcryptjs

Optimized bcrypt in plain JavaScript with zero dependencies. Compatible to 'bcrypt'.

MIT
Latest version published 8 years ago

Package Health Score

70 / 100
Full package analysis