Inside my onCreate
auth cloud function for firebase handler, how can I tell if the user is anonymous, e.g. the isAnonymous
property I get on the client in the onAuthStateChanged
or onIdTokenChanged
response?
exports.createHandler = functions.auth.user().onCreate((user, context) => {
let uid = user.uid,
isAnonymous = ????;
});
It seems that you cannot obtain this information from the Admin SDK. There is no method in the SDK which allows to get it.
The reason is that "isAnonymous
is only a client side construct" as explained here: https://github.com/firebase/firebase-admin-node/issues/127.
isAnonymous
is only a client side construct. If a user is created withsignInAnonymously()
, this flag is set to true (client side only). For example you can use createUser and just create a user without any profile info (no email, phone, password, etc). Would that be considered anonymous? How about if you create a user with just an email? What about a custom auth user? You could also unlink all providers from a non-anonymous account. Would that user become anonymous?Basically, you need to apply your own criteria of what an anonymous user constitutes. When you listUsers you can perhaps check that no providers are linked and no email/phoneNumber is set on the user, etc.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With