function signInWithPopupRedirect(provider) {
  var action = $("input[name=popup-redirect-action]:checked").val();
  var type = $("input[name=popup-redirect-type]:checked").val();
  var method = null;
  var inst = null;
  if (action == 'link' || action == 'reauthenticate') {
    if (!activeUser()) {
      alertError('No user logged in.');
      return;
    }
    inst = activeUser();
    method = action + 'With';
  } else {
    inst = auth;
    method = 'signInWith';
  }
  if (type == 'popup') {
    method += 'Popup';
  } else {
    method += 'Redirect';
  }
  // Get custom OAuth parameters.
  var customParameters = {};
  // For each entry.
  $('form.customParamItem').each(function(index) {
    // Get parameter key.
    var key = $(this).find('input.customParamKey').val();
    // Get parameter value.
    var value = $(this).find('input.customParamValue').val();
    // Save to list if valid.
    if (key && value) {
      customParameters[key] = value;
    }
  });
  console.log('customParameters: ', customParameters);
  // For older jscore versions that do not support this.
  if (provider.setCustomParameters) {
    // Set custom parameters on current provider.
    provider.setCustomParameters(customParameters);
  }

  // Add scopes for providers who do have scopes available (i.e. not Twitter).
  if (provider.addScope) {
    // String.prototype.trim not available in IE8.
    var scopes = $.trim($('#scopes').val()).split(/\s*,\s*/);
    for (var i = 0; i < scopes.length; i++) {
      provider.addScope(scopes[i]);
    }
  }
  console.log('Provider:');
  console.log(provider);
  if (type == 'popup') {
    inst[method](provider).then(function(response) {
      console.log('Popup response:');
      console.log(response);
      alertSuccess(action + ' with ' + provider['providerId'] + ' successful!');
      logAdditionalUserInfo(response);
      onAuthSuccess(activeUser());
    }, onAuthError);
  } else {
    try {
      inst[method](provider).catch(onAuthError);
    } catch (error) {
      console.log('Error while calling ' + method);
      console.error(error);
    }
  }
}
function signInWithPopupRedirect(provider) {
  var action = $("input[name=popup-redirect-action]:checked").val();
  var type = $("input[name=popup-redirect-type]:checked").val();
  var method = null;
  var inst = null;
  if (action == 'link' || action == 'reauthenticate') {
    if (!activeUser()) {
      alertError('No user logged in.');
      return;
    }
    inst = activeUser();
    method = action + 'With';
  } else {
    inst = auth;
    method = 'signInWith';
  }
  if (type == 'popup') {
    method += 'Popup';
  } else {
    method += 'Redirect';
  }
  // Get custom OAuth parameters.
  var customParameters = {};
  // For each entry.
  $('form.customParamItem').each(function(index) {
    // Get parameter key.
    var key = $(this).find('input.customParamKey').val();
    // Get parameter value.
    var value = $(this).find('input.customParamValue').val();
    // Save to list if valid.
    if (key && value) {
      customParameters[key] = value;
    }
  });
  console.log('customParameters: ', customParameters);
  // For older jscore versions that do not support this.
  if (provider.setCustomParameters) {
    // Set custom parameters on current provider.
    provider.setCustomParameters(customParameters);
  }

  // Add scopes for providers who do have scopes available (i.e. not Twitter).
  if (provider.addScope) {
    // String.prototype.trim not available in IE8.
    var scopes = $.trim($('#scopes').val()).split(/\s*,\s*/);
    for (var i = 0; i < scopes.length; i++) {
      provider.addScope(scopes[i]);
    }
  }
  console.log('Provider:');
  console.log(provider);
  if (type == 'popup') {
    inst[method](provider).then(function(response) {
      console.log('Popup response:');
      console.log(response);
      alertSuccess(action + ' with ' + provider['providerId'] + ' successful!');
      logAdditionalUserInfo(response);
      onAuthSuccess(activeUser());
    }, onAuthError);
  } else {
    try {
      inst[method](provider).catch(onAuthError);
    } catch (error) {
      console.log('Error while calling ' + method);
      console.error(error);
    }
  }
}
function signInWithPopupRedirect ( provider ) { var action = $ ( "input[name=popup-redirect-action]:checked" ) . val ( ) ; var type = $ ( "input[name=popup-redirect-type]:checked" ) . val ( ) ; var method = null ; var inst = null ; if ( action == 'link' || action == 'reauthenticate' ) { if ( ! activeUser ( ) ) { alertError ( 'No user logged in.' ) ; return ; } inst = activeUser ( ) ; method = action + 'With' ; } else { inst = auth ; method = 'signInWith' ; } if ( type == 'popup' ) { method += 'Popup' ; } else { method += 'Redirect' ; } // Get custom OAuth parameters. var customParameters = { } ; // For each entry. $ ( 'form.customParamItem' ) . each ( function ( index ) { // Get parameter key. var key = $ ( this ) . find ( 'input.customParamKey' ) . val ( ) ; // Get parameter value. var value = $ ( this ) . find ( 'input.customParamValue' ) . val ( ) ; // Save to list if valid. if ( key && value ) { customParameters [ key ] = value ; } } ) ; console . log ( 'customParameters: ' , customParameters ) ; // For older jscore versions that do not support this. if ( provider . setCustomParameters ) { // Set custom parameters on current provider. provider . setCustomParameters ( customParameters ) ; } // Add scopes for providers who do have scopes available (i.e. not Twitter). if ( provider . addScope ) { // String.prototype.trim not available in IE8. var scopes = $ . trim ( $ ( '#scopes' ) . val ( ) ) . split ( / \s*,\s* / ) ; for ( var i = 0 ; i < scopes . length ; i ++ ) { provider . addScope ( scopes [ i ] ) ; } } console . log ( 'Provider:' ) ; console . log ( provider ) ; if ( type == 'popup' ) { inst [ method ] ( provider ) . then ( function ( response ) { console . log ( 'Popup response:' ) ; console . log ( response ) ; alertSuccess ( action + ' with ' + provider [ 'providerId' ] + ' successful!' ) ; logAdditionalUserInfo ( response ) ; onAuthSuccess ( activeUser ( ) ) ; } , onAuthError ) ; } else { try { inst [ method ] ( provider ) . catch ( onAuthError ) ; } catch ( error ) { console . log ( 'Error while calling ' + method ) ; console . error ( error ) ; } } }
Performs a popup/redirect action based on a given provider and the user's
selections.
@param {!firebase.auth.AuthProvider} provider The provider with which to
sign in.
Performs a popup / redirect action based on a given provider and the user s selections .
Sign in with popup redirect