Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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'));
});
}