Advertisement
Guest User

Untitled

a guest
Nov 16th, 2018
366
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. export default (email, password, done) =>
  2.   User.findOne({
  3.     where: { email },
  4.     include: [{
  5.       model: Roles,
  6.       as: 'Roles'
  7.     }, {
  8.       model: Privileges,
  9.       as: 'Privileges',
  10.     }]
  11.   }).then((user) => {
  12.     if (!user) return done(null, false, { message: `There is no record of the email ${email}.` });
  13.     return user.comparePassword(password, user.password).then(
  14.       (result) => {
  15.         if (result) done(null, user);
  16.         else done(null, false, { message: 'Your email/password combination is incorrect.' });
  17.     });
  18.   }).catch((err) => {
  19.     console.log(err);
  20.     done(null, false, { message: 'Something went wrong trying to authenticate' });
  21.   });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement