let passport = require('passport');
exports.checkuser = function (req, res, next) {
    console.log('req.body.params::::::::::::::::::::::::::::::::::::::::::::', req.body);

    passport.authenticate('local', function (err, user, info) {

        console.log('info : ------------- : ', info);

        if (err) { console.log('err ------------', err); return next(err); }
        if (!user) { console.log('!user ------------', err); return res.send(info); }
        req.logIn(user, function (err) {
            if (err) { console.log('err in logIn ------------', err); return next(err); }

            console.log(user, '<--------:::-- res-- info :::---------->', info);
            console.log('req.session^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', req.session);
            console.log('req.session.passport.user^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^', req.session.passport.user);

            res.json(user);
        });
    })(req, res, next);


}
