Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Will currentUser() return an anonymous user Firebase?

I cannot seem to find this answer anywhere. When randomly authenticating a user with base.auth().signInAnonymously(), and then calling currentUser(), will it return that anonymous user?

Basically, I am trying to figure out if a user is actually logged in, or if they are anonymously authenticated. Please help.

like image 627
Michael Jones Avatar asked Oct 05 '16 02:10

Michael Jones


1 Answers

"Yes, it will", like Frank van Puffelen said. You could get the user:

private lateinit var auth: FirebaseAuth
...
auth = Firebase.auth
val currentUser = auth.currentUser

and if the currentUser exists, you can find out if it is anonymous by using the isAnonymous field:

if (user?.isAnonymous) {
    // Do something
}
like image 143
Jaco Avatar answered Nov 15 '22 11:11

Jaco