auth/google-oauth.js
function setAuthCodeOnReq(req, res, next) {
    if (req.query.code) {
        req.code = req.query.code;
        debug('Found auth code %s on query param', req.code);
        return next();
    }

    //look for something like {"code": "..."}
    if (req.body.code) {
        req.code = req.body.code;
        debug('Found auth code %s in JSON body', req.code);
        return next();
    }

    getRawBody(req, function(err, string) {
        if (err) {
            debug(err);
        }
        if (string.toString().length > 0) {
            req.code = string.toString();
            debug('Found auth code %s in body', req.code);
        }
        next();
    });
}
function setAuthCodeOnReq(req, res, next) {
    if (req.query.code) {
        req.code = req.query.code;
        debug('Found auth code %s on query param', req.code);
        return next();
    }

    //look for something like {"code": "..."}
    if (req.body.code) {
        req.code = req.body.code;
        debug('Found auth code %s in JSON body', req.code);
        return next();
    }

    getRawBody(req, function(err, string) {
        if (err) {
            debug(err);
        }
        if (string.toString().length > 0) {
            req.code = string.toString();
            debug('Found auth code %s in body', req.code);
        }
        next();
    });
}
function setAuthCodeOnReq ( req , res , next ) { if ( req . query . code ) { req . code = req . query . code ; debug ( 'Found auth code %s on query param' , req . code ) ; return next ( ) ; } //look for something like {"code": "..."} if ( req . body . code ) { req . code = req . body . code ; debug ( 'Found auth code %s in JSON body' , req . code ) ; return next ( ) ; } getRawBody ( req , function ( err , string ) { if ( err ) { debug ( err ) ; } if ( string . toString ( ) . length > 0 ) { req . code = string . toString ( ) ; debug ( 'Found auth code %s in body' , req . code ) ; } next ( ) ; } ) ; }
Look for an auth code on a request. The code is either stored on a query param, in a JSON POST body, or as a raw POST body. If found, it sets req.code, otherwise continue on. Uses raw-body library to get the request body so that bodyParser doesn't have to be configured.
Look for an auth code on a request . The code is either stored on a query param in a JSON POST body or as a raw POST body . If found it sets req . code otherwise continue on . Uses raw - body library to get the request body so that bodyParser doesn t have to be configured .