baumblatt / capacitor-firebase-auth

Capacitor Firebase Authentication Plugin
MIT License
261 stars 129 forks source link

Phone auth not catching all errors #87

Closed kedarguy closed 4 years ago

kedarguy commented 4 years ago

My code on the client side

      cfaSignInPhoneOnCodeSent().subscribe(
        (token: string) => {
          setCfaToken(token);
        },
        (error: any) => (): void => {

          console.log(
            `**** Error cfaSignInPhoneOnCodeSent **** ${JSON.stringify(
              error
            )}`
          );
        },

        () => {
    // cfa token sent complete
        }
      );
      cfaSignInPhone(`${finalPhoneNumber}`).subscribe(
        event =>

          console.log(
            `###### event from cfaSignInPhone event: ${JSON.stringify(
              event
            )}`
          ),
        (error: any) => (): void => {
             console.log(`#### error from cfaSignInPhone ${JSON.stringify(error)}`);
        },
        () =>
          console.log("############ data from complete cfaSignInPhone 33333: ")
      );

When I pass an invalid phone number to cfaSignInPhone I dont get any error from the rxjs error function, but I see in the console the following capacitor error:

result CapacitorFirebaseAuth.signIn (#65307546)
index.js:1 
Object
message: "Invalid phone number."
__proto__: Object

Tracing the text to android this error code appears in PhoneProviderHandler

         if (error instanceof FirebaseAuthInvalidCredentialsException) {
                    plugin.handleFailure("Invalid phone number.", error);

So it looks like the handleFailure function isnt working properly? or am I missing a way to catch some of the errors?

This is happening in android, will check ios and update

kedarguy commented 4 years ago

Found my mistake 🤦‍♂️, closing this as it is working as expected