Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Firebase user no longer anonymous after calling updateProfile() method

Within the Android app I create an anonymous user, and later migrate this user's data to a Google/Facebook auth account when the user decides to sign-in.

This has been working fine until using the FirebaseAuth updateProfile() method, whereafter the user is no longer anonymous when you call the isAnonymous() method.

From the Firebase API docs - https://developers.google.com/android/reference/com/google/firebase/auth/FirebaseUser.html#isAnonymous() :

isAnonymous():

Returns true if the user is anonymous; that is, the user account was created with signInAnonymously() and has not been linked to another account with linkWithCredential(AuthCredential).

FirebaseUser updateProfile() method:

FirebaseAuth.getInstance().currentUser?.updateProfile(
                UserProfileChangeRequest.Builder()
                .setDisplayName("Anonymous User")
                .build())

The above method is called so that later in the app I can check the anonymous user's display name and write it to the database etc.

According to the API docs a user is considered anonymous until such stage that linkWithCredential() is called or the user signs in with an auth provider method, so why does the updateProfile() method make the anonymous user no longer anonymous?

like image 725
Benjamin Scholtz Avatar asked Dec 14 '17 13:12

Benjamin Scholtz


People also ask

What does Firebase auth () CurrentUser return?

What does Firebase auth () CurrentUser return? If a user isn't signed in, CurrentUser returns null. Note: CurrentUser might also return null because the auth object has not finished initializing.

Which method will you call to logout a user from Firebase?

If you'd like to sign the user out of their current authentication state, call the signOut method: import auth from '@react-native-firebase/auth'; auth() . signOut() .

How do you check if a user is authenticated in Firebase?

var user = firebase. auth(). currentUser; if (user) { // User is signed in. } else { // No user is signed in. }

What is anonymous user in Firebase?

You can use Firebase Authentication to create and use temporary anonymous accounts to authenticate with Firebase. These temporary anonymous accounts can be used to allow users who haven't yet signed up to your app to work with data protected by security rules.


1 Answers

firebaser here

This is a bug in the Firebase Android SDK. It's been there since version 9.0 was launched around I/O 2016. Now that we know about it, it will be fixed in an upcoming version (although I don't know which version that will be yet).

like image 172
Frank van Puffelen Avatar answered Sep 20 '22 21:09

Frank van Puffelen