function()

in javascript/widgets/handler/common.js [282:355]


    function(app, component, authResult) {
  // Already signed in on external Auth instance. Auth result should
  // contain the current signed in user on external Auth instance.
  // This should not occur.
  if (!authResult['user']) {
    throw new Error('No user found');
  }
  var signInSuccessWithAuthResultCallback =
      app.getConfig().getSignInSuccessWithAuthResultCallback();
  var signInSuccessCallback = app.getConfig().getSignInSuccessCallback();
  // If both old and new signInSuccess callbacks are provided, warn in console
  // that only new callback will be invoked.
  if (signInSuccessCallback && signInSuccessWithAuthResultCallback) {
    var callbackWarning = 'Both signInSuccess and ' +
        'signInSuccessWithAuthResult callbacks are provided. Only ' +
        'signInSuccessWithAuthResult callback will be invoked.';
    firebaseui.auth.log.warning(callbackWarning);
  }
  // If signInSuccessWithAuthResult callback is not provided, fallback to the
  // old signInSuccess callback. To be removed once the signInSuccess callback
  // is removed.
  if (!signInSuccessWithAuthResultCallback) {
    firebaseui.auth.widget.handler.common.setUserLoggedInExternal_(
        app, component, authResult['user'], authResult['credential']);
  } else {
    var callback = app.getConfig().getSignInSuccessWithAuthResultCallback();
    // Finish the flow by redirecting to sign-in success URL.
    // Get redirect URL if it exists in non persistent storage.
    // If signInSuccessWithAuthResult callback defined, pass redirect URL as
    // second parameter.
    // If not defined, override signInSuccessUrl with redirect URL value.
    var redirectUrl = firebaseui.auth.storage.getRedirectUrl(
        app.getAppId()) || undefined;
    // Clear redirect URL from storage if available.
    firebaseui.auth.storage.removeRedirectUrl(app.getAppId());
    // Whether widget is redirecting. Initialize to false.
    var isRedirecting = false;
    if (firebaseui.auth.util.hasOpener()) {
      // Popup sign in.
      if (!callback || callback(authResult, redirectUrl)) {
        // Whether sign-in widget is redirecting.
        isRedirecting = true;
        // signInSuccessUrl is only required if there's no callback or it
        // returns true, and if there's no redirectUrl present.
        firebaseui.auth.util.openerGoTo(
            firebaseui.auth.widget.handler.common.getSignedInRedirectUrl_(
                app, redirectUrl));
      }
      if (!callback) {
        // If the developer supplies a callback, do not close the popup
        // window. Should be closed manually by the developer.
        firebaseui.auth.util.close(window);
      }
    } else {
      // Normal sign in.
      if (!callback || callback(authResult, redirectUrl)) {
        // Sign-in widget is redirecting.
        isRedirecting = true;
        // signInSuccessUrl is only required if there's no callback or it
        // returns true, and if there's no redirectUrl present.
        firebaseui.auth.util.goTo(
            firebaseui.auth.widget.handler.common.getSignedInRedirectUrl_(
                app, redirectUrl));
      }
    }
    // Dispose UI if not already disposed and not redirecting.
    // If the widget is redirecting, it provides better UX to keep the loader
    // showing until the page redirects. Otherwise, (most likely operating in
    // single page mode), hide any remaining widget UI component.
    if (!isRedirecting) {
      app.reset();
    }
  }
};