Register anonymous user via cloud code not being reflected client side


We have a flow that allows anonymous users to register their accounts (signup). The signup happens serverside via cloud code. After this, the user object is updated client side. However, if we check “isLinked” the user still seems anonymous because the pinning of the user object does not remove data, only updates it.

How can we get around this issue?


There is a test case for this or at least similar. Can you submit a Pull Request with a failing test?

Edit: You can log them in on client side after the signup in cloud code


As @dplewis wrote, you will need to sign in the new user, either by doing a proper login or by become-ing the user with the session token returned from CC. If this is not what you want/need, you might just do a fetch on the user object to get the updated state.

1 Like

The issue I’m seeing is that when the fetch is done on the Android side there isn’t an AuthData field being returned because it no longer exists. And my understanding of .pin() is that it only updates or adds fields but doesn’t remove them. So AuthData still exists client side.

I don’t want to force the user to log out and then log back in.


IIRC authData is not transmitted by normal fetching for privacy reasons (you can test this by trying to fetch with the masterKey option, in which case authData should be present).


As @dr_barto suggested, I think your best option is to use the become method in the client side.