code: function makeLoginHandler(provider, providerAccounts) {
    return function (accessToken, refreshToken, profile, done) {
      log.debug('Authentiated for ' + provider);
      log.debug(profile);
  
      profile.provider = provider;
      profile.idWithProvider = profile.id;
      exports.getUserFromProfile(providerAccounts, profile)
        .then(function (userRecord) {
  
          // Save the user if they are new.
          var fieldsToCopy = ['provider', 'displayName', 'emails'];
          if (userRecord && userRecord.data) {
  
            return userRecord;
          } else {
            userRecord = {
              isAuthenticated: true
            };
            userRecord.meta = {
              isRegistered: false
            };
            userRecord.data = {
              idWithProvider: profile.id,
            };
            fieldsToCopy.forEach(function (key) {
              userRecord.data[key] = profile[key];
            });
  
            return providerAccounts.create(userRecord.data)
              .then(function () {
                return userRecord;
              });
          }
        })
        .then(function (userRecord) {
          done(null, userRecord);
        })
        .then(null, function (error) {
          log.error(error);
          done(error);
        })
        .then(null, log.error);
    };
  }
docs: Makes a handler to be called after the user was authenticated with an OAuth provider.