capawesome-team / capacitor-firebase

⚡️ Firebase plugins for Capacitor. Supports Android, iOS and the Web.

Home Page:https://capawesome.io/plugins/firebase/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

feat(authentication): add `fetchSignInMethodsForEmail(...)` method

DontGiveAFck opened this issue · comments

Plugin(s)

  • Analytics
  • App
  • App Check
  • Authentication
  • Crashlytics
  • Cloud Firestore
  • Cloud Messaging
  • Cloud Storage
  • Performance
  • Remote Config

Current problem

On account-exists-with-different-credential error code user should be forced to use sign in method that was used previously, but when this error thrown there is no way to detect available sign in methods.

Preferred solution

When account-exists-with-different-credential happens, error object should also contain availableProviders property (or email property and fetchSignInMethodsForEmail method should be implemented in plugin).

Alternative options

No response

Additional context

No response

Before submitting

The fetchSignInMethodsForEmail method seems to be deprecated on the native platforms, see Firebase docs.

Can you share a link to the docs regarding the availableProviders property?

@robingenz

availableProviders prop doesn't exists, I just wrote it as an example of another prop that might exist. (Looks like that it doesn't)

Possible solution - signInWithCredentials method throws FirebaseAuthUserCollisionException exception that contains email field and it can be used with firebase js sdk at least to handle this error somehow. Because now we forced to ask user to type email manually and check available providers that sounds like an issue.

Firebase docs

@robingenz

Regarding fetchSignInMethodsForEmail - yes, it's deprecated but it would be nice to have it if we will know user's email from solution above, so firebase js sdk will be not needed and issue will be fixed.

Please give this dev build a try and let me know if everything works as expected:

npm i @capacitor-firebase/authentication@5.4.1-dev.e2f5589.1711099069

@robingenz
I checked this build:

  1. There is still no user email returned from login error. I mentioned possible fix in this comment
  2. fetchSignInMethodsForEmail works fine on ios, but on android there is an issue (screenshot attached)
Screenshot 2024-03-22 at 13 54 36
  1. Yes, this PR only covers the fetchSignInMethodsForEmail method for now. Please create a separate issue for the FirebaseAuthUserCollisionException.
  2. Thanks, I will fix it for Android.