Guest User

Untitled

a guest
Oct 10th, 2017
24
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.83 KB | None | 0 0
  1. exports.adminLogin = function(req, cb) {
  2. console.log('adminLogin', req);
  3.  
  4. Admin.find({
  5. where: { username: req.username, isActive: true },
  6. attributes: ['id', 'username', 'fName', 'lName',
  7. 'role', 'password'
  8. ],
  9. raw: true
  10. }).then(function(admin, err) {
  11. if (admin && compare(req.password, admin.password)) {
  12.  
  13. admin.password = undefined;
  14. cb(admin);
  15. } else if (err) {
  16. console.log('adminLogin findOne err:', err);
  17. cb(false);
  18. } else if (!!admin && !compare(req.password, admin.password)) {
  19. cb('Wrong password');
  20. } else {
  21. cb('No account found');
  22. }
  23. });
  24. }
Add Comment
Please, Sign In to add comment