Conversation
|
@yramanchuk I believe the result of that issue was that FirebaseUI isn't going to support this kind of flow. Could you explain why you already have a phone number? The user should be giving that to FirebaseUI in the auth flow, not to you directly. Hope this clears things up! 😄 |
|
@yramanchuk I think the issue that is linked to may not be completely comparable. @SUPERCILEX The problem we are addressing is rooted in the fact that Firebase UI currently does not support 2FA (Say Facebook + Phone Auth). To work around this, apps that wish to use phone as the second factor can use Facebook login on their own outside Firebase UI and then use Firebase UI for the second factor phone auth. |
|
@ashwinraghav Thanks for the clarification. Here's related FirebaseUI-iOS issue: firebase/FirebaseUI-iOS#306 |
| break; | ||
| case AuthUI.PHONE_VERIFICATION_PROVIDER: | ||
| mProviders.add(new PhoneProvider(this, getFlowParams())); | ||
| PhoneIdpConfig phoneIdpConfig = (PhoneIdpConfig) idpConfig; |
There was a problem hiding this comment.
Would this break older clients, breaking backward compatibility?
| } | ||
| } | ||
|
|
||
| public static class PhoneIdpConfig extends IdpConfig { |
There was a problem hiding this comment.
I feel like introducing a config per for phone auth provider leaves me desiring symmetry for such a config in other providers.
Also, the type safety that this implementation gives is hard to enforce in a backward compatible way. This leads to unsafe typecasting like the one made in
My suggestion would be to introduce a Bundle parameter into the existing IdpConfig that yields an API that would look like:
Bundle b = new Bundle();
b.putString(AuthUI.PHONE_VERIFICATION_PROVIDER.DEFAULT_PHONE_EXTRA, "+16478488383");
new AuthUI.IdpConfig.Builder(AuthUI.PHONE_PROVIDER).setParams(bundle).build()) and wire it into the providers from that point on.
There was a problem hiding this comment.
@ashwinraghav Thhank's for the suggestion. I was thinking about extending existing IdpConfig but in that case were are adding changes to all configs (Google, Facebook) and they they don't need that parameter.
Anyway I think your solution is more elegant. I just want to propose to use List of Bundles instead of just Bundle:
AuthUI.IdpConfig.Builder(AuthUI.PHONE_PROVIDER).setParams(List).build())
In that case we can pass multiple params.
@ashwinraghav what do you think?
|
@yramanchuk FYI I changed the target branch to the current development branch, |
|
Note that the issue of IDP-specific configuration has been discussed here as well: |
samtstern
left a comment
There was a problem hiding this comment.
Mostly good, a few remaining comments,
| // Use the params Bundle to provide a default phone number that will populate the | ||
| // phone number field in PhoneVerificationActivity if the number is known in advance. | ||
| Bundle params = new Bundle(); | ||
| params.putString(AuthUI.PHONE_VERIFICATION_DEFAULT_PHONE_EXTRA, "+13099126574"); |
There was a problem hiding this comment.
This is a minor point, but I think putting a random phone number into the sample will cause confusion. Many people will want to use this sample to test phone auth with their real number.
This type of example snippet belongs in the README.
There was a problem hiding this comment.
Moved to README, let me know if you don't think it's in an appropriate location.
| .getString(AuthUI.PHONE_VERIFICATION_DEFAULT_PHONE_EXTRA); | ||
| startActivityForResult( | ||
| PhoneVerificationActivity.createIntent(getContext(), flowParams, null), | ||
| PhoneVerificationActivity.createIntent(getContext(), flowParams, phone), |
There was a problem hiding this comment.
This createIntent call uses ExtraConstants.EXTRA_PHONE. We should unify the values between this and AuthUI.PHONE_VERIFICATION_DEFAULT_PHONE_EXTRA.
I'd suggest:
class AuthUI {
// ...
public static final String EXTRA_DEFAULT_PHONE = ExtraConstants.EXTRA_PHONE;
// ...
}There was a problem hiding this comment.
That's reasonable, made your suggested change.
| break; | ||
| case AuthUI.PHONE_VERIFICATION_PROVIDER: | ||
| mProviders.add(new PhoneProvider(this, getFlowParams())); | ||
| PhoneIdpConfig phoneIdpConfig = (PhoneIdpConfig) idpConfig; |
There was a problem hiding this comment.
This class PhoneIdpConfig is used here but I don't see it defined in this PR anymore. I think changes to this file need to be revisited.
|
@SUPERCILEX the main reason for supporting this flow is feature parity with what Digits used to offer. We are telling all Digits developers to move to FirebaseUI and some of them noticed this missing feature. You are right though, it was not a flow we originally intended to support. Ashwin and Yury have provided some examples where it can be very useful though. |
SUPERCILEX
left a comment
There was a problem hiding this comment.
@yramanchuk @ashwinraghav @samtstern Thanks for all your explanations, I see why this is necessary now!
@yramanchuk I just have a few comments.
| selectedProviders.add( | ||
| new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER).build()); | ||
| new IdpConfig.Builder(AuthUI.PHONE_VERIFICATION_PROVIDER) | ||
| .build()); |
There was a problem hiding this comment.
Might as well undo the changes in this file since they're leftovers from previous commits.
| paramsValueBuilder.append(mParams.get(key).toString()); | ||
| paramsValueBuilder.append(","); | ||
| } | ||
| paramsValueBuilder.append("}"); |
There was a problem hiding this comment.
Doesn't Bundle already have a toString() with very similar behavior?
There was a problem hiding this comment.
Yeah, just check the source and Bundle#toString() calls mMap.toString(). I'm assuming the formatting will be a little bit different, but the output should be effectively the same.
There was a problem hiding this comment.
Ah, did not realize that. Switched to the Bundle toString.
| String phone = null; | ||
| for (AuthUI.IdpConfig idpConfig : mFlowParameters.providerInfo) { | ||
| if (idpConfig.getProviderId().equals(AuthUI.PHONE_VERIFICATION_PROVIDER)) { | ||
| phone = idpConfig.getParams().getString(EXTRA_DEFAULT_PHONE); |
There was a problem hiding this comment.
To be consistent, we shouldn't statically import this and instead use AuthUI.EXTRA_DEFAULT_PHONE.
| case PhoneAuthProvider.PROVIDER_ID: | ||
| // Go directly to phone flow | ||
| String phone = idpConfigs | ||
| .get(0) |
There was a problem hiding this comment.
This same logic is used above so we should probably extract a firstIdpConfig and replace firstProvider with the method call.
| private IdpConfig(Parcel in) { | ||
| mProviderId = in.readString(); | ||
| mScopes = Collections.unmodifiableList(in.createStringArrayList()); | ||
| mParams = in.readBundle(); |
There was a problem hiding this comment.
This should be in.readBundle(getClass().getClassLoader()) to make the build pass. Since we're just passing in strings right now we don't actually need this, but it'll ensure we're future proof (and make lint happy).
There was a problem hiding this comment.
Ah, just noticed the CONTRIBUTING.md file. Apologies - just beginning contribution to the library and obviously wasn't paying full attention. Made the change and build should be passing now. Thanks for the review by the way!
| return "IdpConfig{" + | ||
| "mProviderId='" + mProviderId + '\'' + | ||
| ", mScopes=" + mScopes + | ||
| ", mParams=" + mParams.toString() + |
There was a problem hiding this comment.
One last nit! 😄 We don't need the toString() call, mParams alone is just fine.
SUPERCILEX
left a comment
There was a problem hiding this comment.
@yramanchuk Sweet, LGTM! 😄
|
I will merge this once Travis is happy. |
Implement phone Auth flow Phone number configuration parameter.
Related issue #887