baumblatt / capacitor-firebase-auth

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

cfaSignInGoogle() userCredential always returns isNewUser to false #151

Open cristiantrapero opened 3 years ago

cristiantrapero commented 3 years ago

When I try to sign in using direct Google method as show in the code:

import * as firebase from 'firebase/app';
import { cfaSignInGoogle, SignInResult} from 'capacitor-firebase-auth/alternative';

cfaSignInGoogle().subscribe(
      ({userCredential, result}: {userCredential: firebase.auth.UserCredential, result: SignInResult}) => {
        console.log("Result: ", result)
        console.log("User credential: ", userCredential);
        console.log("New user: ", userCredential.additionalUserInfo.isNewUser)
      });

The variable userCredential.additionalUserInfo.isNewUser always returns false due to double login in the calling on native layer and in on web layer. See more in: https://github.com/baumblatt/capacitor-firebase-auth/blob/fb33374ae21e7eb7b0dda984f8c6f4a344360510/src/alternative/alternative.ts#L49

If the user does not exist in Firebase, in the first login it is registered and the variable isNewUser is true, but as in this case we log in a second time in the web layer, so this variable becomes false. That's why this variable is always returned to false, we have to return the first userCredential.

charles-sunflower commented 3 years ago

any plans on fixing this?

how could i fix this locally?

nickweinberg commented 3 years ago

Running into this same issue. Any updates?