Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- exports.adminLogin = function(req, cb) {
- console.log('adminLogin', req);
- Admin.find({
- where: { username: req.username, isActive: true },
- attributes: ['id', 'username', 'fName', 'lName',
- 'role', 'password'
- ],
- raw: true
- }).then(function(admin, err) {
- if (admin && compare(req.password, admin.password)) {
- admin.password = undefined;
- cb(admin);
- } else if (err) {
- console.log('adminLogin findOne err:', err);
- cb(false);
- } else if (!!admin && !compare(req.password, admin.password)) {
- cb('Wrong password');
- } else {
- cb('No account found');
- }
- });
- }
Add Comment
Please, Sign In to add comment