Skip to content

Handle dynamic list of identity providers #1775

Closed
@robapaul88

Description

@robapaul88
  1. have a dynamic list of identity providers in place (by user rights for example)
  2. define a custom layout that adds support for all possible idps

Observed Results:

  • the non-supported ones will still have their buttons shown but not-working

Expected Results:

  • the non-supported ones should be hidden (simplest fix)

Relevant Code:

com.firebase.ui.auth.ui.idp.AuthMethodPickerActivity#populateIdpListCustomLayout should have this content (it also has some safer checks than the existing one):

Map<String, Integer> providerButtonIds = customLayout.getProvidersButton();
      for (IdpConfig idpConfig : providerConfigs) {
          final String providerId = providerOrEmailLinkProvider(idpConfig.getProviderId());

          Integer buttonResId = providerButtonIds.get(providerId);
          if (buttonResId == null) {
              throw new IllegalStateException("No button found for auth provider: " + idpConfig.getProviderId());
          }

          @IdRes int buttonId = buttonResId;
          View loginButton = findViewById(buttonId);
          handleSignInOperation(idpConfig, loginButton);
      }
      //hide custom layout buttons that don't have their identity provider set
      for (String providerBtnId : providerButtonIds.keySet()) {
          if (providerBtnId == null) continue;
          boolean hasProvider = false;
          for (IdpConfig idpConfig : providerConfigs) {
              if (providerBtnId.equals(idpConfig.getProviderId())) {
                  hasProvider = true;
                  break;
              }
          }
          if (!hasProvider) {
              Integer resId = providerButtonIds.get(providerBtnId);
              if (resId == null) continue;
              @IdRes int buttonId = resId;
              findViewById(buttonId).setVisibility(View.GONE);
          }
      }

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions