UNPKG

@speakr/speakr-module-services

Version:
28 lines (23 loc) 633 B
"use strict"; const bcrypt = require('bcryptjs'); module.exports = { password }; function password(options){ return new Promise((resolve, reject) => { if (options.password == null) { return reject('Password is blank.'); } if (options.password != options.password_confirmation) { return reject('Passwords do not match.'); } return bcrypt.hash(options.password, 5, function(err, bcryptedPassword) { if (err) { return reject('Unable to create password.'); } else { options.encrypted_password = bcryptedPassword; return resolve(options); } }); }) }