index.js
function (req, res, passport, cb) {
        let authentication = req.soajs.inputmaskData.strategy;

        passportLib.getDriver(req, false, function (err, passportDriver) {
            passportDriver.preAuthenticate(req, function () {
                passport.authenticate(authentication, {session: false}, function (err, user) {
                    if (err) {
                        req.soajs.log.error(err);
                        return cb({"code": 499, "msg": err.toString()});
                    }
                    if (!user) {
                        cb({"code": 403, "msg": req.soajs.config.errors[403]});
                    }

                    req.soajs.inputmaskData.user = user;
                    initBLModel(req.soajs, function (err) {
                        if (err) {
                            return cb(err);
                        }
                        let mode = req.soajs.inputmaskData.strategy;
                        utilities.saveUser(req.soajs, driver.model, mode, user, function (error, data) {
                            cb(error, data);
                        });
                    });
                })(req, res);

            });
        });

    }
function (req, res, passport, cb) {
        let authentication = req.soajs.inputmaskData.strategy;

        passportLib.getDriver(req, false, function (err, passportDriver) {
            passportDriver.preAuthenticate(req, function () {
                passport.authenticate(authentication, {session: false}, function (err, user) {
                    if (err) {
                        req.soajs.log.error(err);
                        return cb({"code": 499, "msg": err.toString()});
                    }
                    if (!user) {
                        cb({"code": 403, "msg": req.soajs.config.errors[403]});
                    }

                    req.soajs.inputmaskData.user = user;
                    initBLModel(req.soajs, function (err) {
                        if (err) {
                            return cb(err);
                        }
                        let mode = req.soajs.inputmaskData.strategy;
                        utilities.saveUser(req.soajs, driver.model, mode, user, function (error, data) {
                            cb(error, data);
                        });
                    });
                })(req, res);

            });
        });

    }
function ( req , res , passport , cb ) { let authentication = req . soajs . inputmaskData . strategy ; passportLib . getDriver ( req , false , function ( err , passportDriver ) { passportDriver . preAuthenticate ( req , function ( ) { passport . authenticate ( authentication , { session : false } , function ( err , user ) { if ( err ) { req . soajs . log . error ( err ) ; return cb ( { "code" : 499 , "msg" : err . toString ( ) } ) ; } if ( ! user ) { cb ( { "code" : 403 , "msg" : req . soajs . config . errors [ 403 ] } ) ; } req . soajs . inputmaskData . user = user ; initBLModel ( req . soajs , function ( err ) { if ( err ) { return cb ( err ) ; } let mode = req . soajs . inputmaskData . strategy ; utilities . saveUser ( req . soajs , driver . model , mode , user , function ( error , data ) { cb ( error , data ) ; } ) ; } ) ; } ) ( req , res ) ; } ) ; } ) ; }
Get driver, do what is needed before authenticating, and authenticate
Get driver do what is needed before authenticating and authenticate