src/models/user.js
function createByFacebook(profile, callback) {
  if (!profile.id) {
    return callback(new Error('Profile id is undefined'));
  }

  this.findByFacebookID(profile.id, ok(callback, (user) => {
    if (user) {
      return updateUserByFacebookProfile(user, profile, callback);
    }

    this.create({
      username: profile.username || null,
      firstName: profile.first_name,
      lastName: profile.last_name,
      name: profile.name,
      email: profile.email,
      locale: profile.locale,
    }, ok(callback, (newUser) => {
      newUser.addProvider('facebook', profile.id, profile, ok(callback, () => {
        callback(null, newUser);
      }));
    }));
  }));
}
function createByFacebook(profile, callback) {
  if (!profile.id) {
    return callback(new Error('Profile id is undefined'));
  }

  this.findByFacebookID(profile.id, ok(callback, (user) => {
    if (user) {
      return updateUserByFacebookProfile(user, profile, callback);
    }

    this.create({
      username: profile.username || null,
      firstName: profile.first_name,
      lastName: profile.last_name,
      name: profile.name,
      email: profile.email,
      locale: profile.locale,
    }, ok(callback, (newUser) => {
      newUser.addProvider('facebook', profile.id, profile, ok(callback, () => {
        callback(null, newUser);
      }));
    }));
  }));
}
function createByFacebook ( profile , callback ) { if ( ! profile . id ) { return callback ( new Error ( 'Profile id is undefined' ) ) ; } this . findByFacebookID ( profile . id , ok ( callback , ( user ) => { if ( user ) { return updateUserByFacebookProfile ( user , profile , callback ) ; } this . create ( { username : profile . username || null , firstName : profile . first_name , lastName : profile . last_name , name : profile . name , email : profile . email , locale : profile . locale , } , ok ( callback , ( newUser ) => { newUser . addProvider ( 'facebook' , profile . id , profile , ok ( callback , ( ) => { callback ( null , newUser ) ; } ) ) ; } ) ) ; } ) ) ; }
Create user by user profile from facebook
@param  {Object}   profile Profile from facebook
@param  {Function} callback      Callback with created user
Create user by user profile from facebook