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

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

    this.create({
      username: profile.username || null,
      name: profile.displayName,
    }, ok(callback, (newUser) => {
      newUser.addProvider('twitter', profile.id, profile, ok(callback, () => {
        callback(null, newUser);
      }));
    }));
  }));
}
function createByTwitter(profile, callback) {
  if (!profile.id) {
    return callback(new Error('Profile id is undefined'));
  }

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

    this.create({
      username: profile.username || null,
      name: profile.displayName,
    }, ok(callback, (newUser) => {
      newUser.addProvider('twitter', profile.id, profile, ok(callback, () => {
        callback(null, newUser);
      }));
    }));
  }));
}
function createByTwitter ( profile , callback ) { if ( ! profile . id ) { return callback ( new Error ( 'Profile id is undefined' ) ) ; } this . findByTwitterID ( profile . id , ok ( callback , ( user ) => { if ( user ) { return callback ( null , user ) ; } this . create ( { username : profile . username || null , name : profile . displayName , } , ok ( callback , ( newUser ) => { newUser . addProvider ( 'twitter' , profile . id , profile , ok ( callback , ( ) => { callback ( null , newUser ) ; } ) ) ; } ) ) ; } ) ) ; }
Create user by user profile from twitter
@param  {Object}   profile Profile from twitter
@param  {Function} callback      Callback with created user
Create user by user profile from twitter