cb = function(user) {
    if (user &&
        // If email already exists, user must first be signed in to the
        // existing account on the internal Auth instance before the credential
        // is linked and merge conflict is triggered.
        !firebaseui.auth.storage.getPendingEmailCredential(self.getAppId())) {
      // For anonymous user upgrade, call link with redirect on the external
      // user. Otherwise merge conflict will always occur when linking the
      // credential to the external anonymous user after creation.
      return user.linkWithRedirect(provider);
    } else {
      // Starts sign in with redirect. This runs on the internal Auth instance
      // as finish sign in will sign in with the final credential to developer
      // Auth instance.
      return self.getAuth().signInWithRedirect(provider);
    }
  }
Signs in to Auth provider via redirect.
@param {!firebase.auth.AuthProvider} provider The Auth provider to sign in
    with.
@return {!firebase.Promise<void>}