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