@@ -117,7 +117,9 @@ private void populateIdpList(List<IdpConfig> providerConfigs,
117
117
for (IdpConfig idpConfig : providerConfigs ) {
118
118
final ProviderSignInBase <?> provider ;
119
119
@ LayoutRes int buttonLayout ;
120
- switch (idpConfig .getProviderId ()) {
120
+
121
+ final String providerId = idpConfig .getProviderId ();
122
+ switch (providerId ) {
121
123
case GoogleAuthProvider .PROVIDER_ID :
122
124
GoogleSignInHandler google = supplier .get (GoogleSignInHandler .class );
123
125
google .init (new GoogleSignInHandler .Params (idpConfig ));
@@ -154,7 +156,7 @@ private void populateIdpList(List<IdpConfig> providerConfigs,
154
156
buttonLayout = R .layout .fui_provider_button_phone ;
155
157
break ;
156
158
default :
157
- throw new IllegalStateException ("Unknown provider: " + idpConfig . getProviderId () );
159
+ throw new IllegalStateException ("Unknown provider: " + providerId );
158
160
}
159
161
mProviders .add (provider );
160
162
@@ -175,7 +177,12 @@ private void handleResponse(@NonNull IdpResponse response) {
175
177
// We have no idea what provider this error stemmed from so just forward
176
178
// this along to the handler.
177
179
handler .startSignIn (response );
178
- } else if (AuthUI .SOCIAL_PROVIDERS .contains (response .getProviderType ())) {
180
+ } else if (AuthUI .SOCIAL_PROVIDERS .contains (providerId )) {
181
+ // Don't use the response's provider since it can be different than the one
182
+ // that launched the sign-in attempt. Ex: the email flow is started, but
183
+ // ends up turning into a Google sign-in because that account already
184
+ // existed. In the previous example, an extra sign-in would incorrectly
185
+ // started.
179
186
handler .startSignIn (response );
180
187
} else {
181
188
// Email or phone: the credentials should have already been saved so simply
0 commit comments