middleware/mw.auth.social.js
function getProvider(providerName, providerConfig) {
        return _.extend({}, providerConfig.opts, {
            profile: function profile(credentials, params, get, callback) {
                var proof = null;

                /* eslint camelcase:0 */
                if (providerConfig.useProof) {
                    proof = {
                        appsecret_proof: crypto
                            .createHmac('sha256', this.clientSecret)
                            .update(credentials.token)
                            .digest('hex')
                    };
                }

                get(providerConfig.url, proof, function (data) {
                    credentials.profile = {
                        authType:           providerName,
                        email:              data.email,
                        emailLower:         data.email && data.email.toLowerCase(),
                        emailConfirmed:     data.verified,
                        name: {
                            firstName:      data.given_name || '',
                            lastName:       data.family_name || '',
                            displayName:    data.name || ''
                        }
                    };

                    if (providerName === 'google') {
                        credentials.profile.profileImg = data.picture;
                        credentials.profile.googleAuthData = data;
                    }
                    else if (providerName === 'facebook') {
                        credentials.profile.profileImg = 'https://graph.facebook.com/' +
                            data.id + '/picture?width=80&height=80';
                        credentials.profile.fbAuthData = data;
                    }

                    return callback();
                });
            }
        });
    }
function getProvider(providerName, providerConfig) {
        return _.extend({}, providerConfig.opts, {
            profile: function profile(credentials, params, get, callback) {
                var proof = null;

                /* eslint camelcase:0 */
                if (providerConfig.useProof) {
                    proof = {
                        appsecret_proof: crypto
                            .createHmac('sha256', this.clientSecret)
                            .update(credentials.token)
                            .digest('hex')
                    };
                }

                get(providerConfig.url, proof, function (data) {
                    credentials.profile = {
                        authType:           providerName,
                        email:              data.email,
                        emailLower:         data.email && data.email.toLowerCase(),
                        emailConfirmed:     data.verified,
                        name: {
                            firstName:      data.given_name || '',
                            lastName:       data.family_name || '',
                            displayName:    data.name || ''
                        }
                    };

                    if (providerName === 'google') {
                        credentials.profile.profileImg = data.picture;
                        credentials.profile.googleAuthData = data;
                    }
                    else if (providerName === 'facebook') {
                        credentials.profile.profileImg = 'https://graph.facebook.com/' +
                            data.id + '/picture?width=80&height=80';
                        credentials.profile.fbAuthData = data;
                    }

                    return callback();
                });
            }
        });
    }
function getProvider ( providerName , providerConfig ) { return _ . extend ( { } , providerConfig . opts , { profile : function profile ( credentials , params , get , callback ) { var proof = null ; /* eslint camelcase:0 */ if ( providerConfig . useProof ) { proof = { appsecret_proof : crypto . createHmac ( 'sha256' , this . clientSecret ) . update ( credentials . token ) . digest ( 'hex' ) } ; } get ( providerConfig . url , proof , function ( data ) { credentials . profile = { authType : providerName , email : data . email , emailLower : data . email && data . email . toLowerCase ( ) , emailConfirmed : data . verified , name : { firstName : data . given_name || '' , lastName : data . family_name || '' , displayName : data . name || '' } } ; if ( providerName === 'google' ) { credentials . profile . profileImg = data . picture ; credentials . profile . googleAuthData = data ; } else if ( providerName === 'facebook' ) { credentials . profile . profileImg = 'https://graph.facebook.com/' + data . id + '/picture?width=80&height=80' ; credentials . profile . fbAuthData = data ; } return callback ( ) ; } ) ; } } ) ; }
Get the provider info which is really opts from the config plus the
profile function which sets the values which we will store in the
user table in the database

@param providerName
@param providerConfig
@returns {*}
Get the provider info which is really opts from the config plus the profile function which sets the values which we will store in the user table in the database