baumblatt / capacitor-firebase-auth

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

Possible bug on phone auth #216

Open betocantu93 opened 2 years ago

betocantu93 commented 2 years ago

Hello, thanks for the amazing work.

Suddenly my app stopped building, not sure if one of my deps updated or something. But suddenly this line stopped working...

https://github.com/baumblatt/capacitor-firebase-auth/blob/7a62d887e0189b2d4196d7dc519c14635e6deaae/ios/Plugin/Handlers/PhoneNumberProvider.swift#L34

Screen Shot 2022-05-09 at 23 59 26

I "patched it" like this, not sure if its the right approach?

Screen Shot 2022-05-09 at 23 59 43

Thnaks

betocantu93 commented 2 years ago

It seems there was a breaking change

https://github.com/firebase/firebase-ios-sdk/issues/7723

Darrow8 commented 2 years ago

+1

I had this same issue, and eventually just did this:

if let error = error {
                 let errCode = AuthErrorCode(AuthErrorCode.Code(rawValue: error._code) ?? AuthErrorCode.internalError)
                    switch errCode {
                    case AuthErrorCode.quotaExceeded:
                        call.reject("Quota exceeded.")
                    case AuthErrorCode.invalidPhoneNumber:
                        call.reject("Invalid phone number.")
                    case AuthErrorCode.captchaCheckFailed:
                        call.reject("Captcha Check Failed")
                    case AuthErrorCode.missingPhoneNumber:
                        call.reject("Missing phone number.")
                    default:
                        call.reject("PhoneAuth Sign In failure: \(String(describing: error))")
                    }

                    return
            }

The issue looks to be related to how this library handles errors, and the authcodes that used to exist on firebase auth have changed.

Hopefully the maintainers of this library release an update to address this breaking change.

betocantu93 commented 2 years ago

Yea, firebase update had a breaking change.

One question @Darrow8 , how do you override this code? Do you published another package to npm? Or how do you make sure other devs on your team get these changes?

I'm not a native dev so I struggled, forked and published a new package

https://github.com/betocantu93/capacitor-firebase-auth/tree/release-npm

published as bengala-capacitor-firebase-auth

Darrow8 commented 2 years ago

@betocantu93 oh okay cool, I did not publish a new package, I just directly edited the library code for my local version.

galaxyblur commented 2 years ago

@Darrow8 your fix worked for me, thanks. (I don't even use Phone auth and this error was blocking me.)

I think the maintainer, @baumblatt , needs some help or funding. I would absolutely contribute in whatever way possible. I am also not a native dev, but happy to contribute some money or JS code. @baumblatt please let us know what we can do to keep this library alive! Thanks for the work you've done so far.