BLKKKBVSIK
BLKKKBVSIK

Reputation: 3566

fireauth detect user creation

I'm using FireAuth to sign up my users, but i'm not using FireCloud (because we use our own back-end cloud database), and I would like to know if when a user connect with Google Sign In, if it is the first time or not he connect (to know if it create the user an account or simply log into one).

I've found this on the documentation of Firebase, it look perfect, but it's in beta and I don't seem to find the correct method with the dart package.

https://firebase.google.com/docs/functions/auth-events

Hope you can help me !
Thanks you for reading !

Upvotes: 0

Views: 25

Answers (1)

Peter Haddad
Peter Haddad

Reputation: 80934

You can use isNewUser, which will return if the user is logging in for the first time:

AuthResult user = await auth.signInWithCredential(credential);
print(user.additionalUserInfo.isNewUser);

https://github.com/FirebaseExtended/flutterfire/blob/master/packages/firebase_auth/firebase_auth/lib/src/additional_user_info.dart

Upvotes: 1

Related Questions