lib/security/providers/facebook.js
function _createNewFacebookUser() {
    var avatar = '',
        excludedFields = ['link', 'email', 'first_name', 'last_name','picture'],
        newUser;

    //Set Image
    if(this.socialUserInfo.picture && this.socialUserInfo.picture.data && this.socialUserInfo.picture.data.url !== ''){
        avatar = this.socialUserInfo.picture.data.url;
    }

    newUser = {
        role: 'external',
        identities: {
            facebook: {
                id: this.socialUserInfo.id,
                accessToken: this.creds.access_token,
                expiresIn: this.creds.expires
            }
        },
        linkedidentities: ['facebook'],
        profile: {
            picture: avatar
        },
        enabled: true,
        email: this.socialUserInfo.email,
        firstname: this.socialUserInfo.first_name,
        lastname: this.socialUserInfo.last_name
    };

    _.each(profileFieldsArr, function(field){
        if(excludedFields.indexOf(field) === -1){
            newUser.profile[field] = this.socialUserInfo[field];
        }
    }.bind(this));

    return db.users.insert(newUser);
}
function _createNewFacebookUser() {
    var avatar = '',
        excludedFields = ['link', 'email', 'first_name', 'last_name','picture'],
        newUser;

    //Set Image
    if(this.socialUserInfo.picture && this.socialUserInfo.picture.data && this.socialUserInfo.picture.data.url !== ''){
        avatar = this.socialUserInfo.picture.data.url;
    }

    newUser = {
        role: 'external',
        identities: {
            facebook: {
                id: this.socialUserInfo.id,
                accessToken: this.creds.access_token,
                expiresIn: this.creds.expires
            }
        },
        linkedidentities: ['facebook'],
        profile: {
            picture: avatar
        },
        enabled: true,
        email: this.socialUserInfo.email,
        firstname: this.socialUserInfo.first_name,
        lastname: this.socialUserInfo.last_name
    };

    _.each(profileFieldsArr, function(field){
        if(excludedFields.indexOf(field) === -1){
            newUser.profile[field] = this.socialUserInfo[field];
        }
    }.bind(this));

    return db.users.insert(newUser);
}
function _createNewFacebookUser ( ) { var avatar = '' , excludedFields = [ 'link' , 'email' , 'first_name' , 'last_name' , 'picture' ] , newUser ; //Set Image if ( this . socialUserInfo . picture && this . socialUserInfo . picture . data && this . socialUserInfo . picture . data . url !== '' ) { avatar = this . socialUserInfo . picture . data . url ; } newUser = { role : 'external' , identities : { facebook : { id : this . socialUserInfo . id , accessToken : this . creds . access_token , expiresIn : this . creds . expires } } , linkedidentities : [ 'facebook' ] , profile : { picture : avatar } , enabled : true , email : this . socialUserInfo . email , firstname : this . socialUserInfo . first_name , lastname : this . socialUserInfo . last_name } ; _ . each ( profileFieldsArr , function ( field ) { if ( excludedFields . indexOf ( field ) === - 1 ) { newUser . profile [ field ] = this . socialUserInfo [ field ] ; } } . bind ( this ) ) ; return db . users . insert ( newUser ) ; }
Function that takes the facebook social data and attaches it to a user in grasshopper
Function that takes the facebook social data and attaches it to a user in grasshopper