How would you implement an automatic registration and login with device id?

Okay I honestly had a hard time to phrase the question.

That’s why I will just describe what I want to achieve:

I’m using the Realm Web SDK.
When a user opens my app for the first time he should be automatically signed in to mongodb. Maybe through his device ID or some random ID that is generated through a function.
The user should be able to use basic functionality of the app from the go (but restricted of course) and then he can later decide if he wants to create an account.

I saw this approach in free to play games which let you start to play their game without any (visible) registration process and your progress and data is still saved in the database. But if you want to do more specific things like joining a guild you are prompted to make an account.

How would this be possible with Mongodb Realm and the Web SDK?

PS: I know some intermediate Javascript but I’m not a super skilled backend binary code hacker.

I think the best way to do this would be to use Anonymous authentication for new users. You can limit anonymous users in your rules while still letting them interact with the app. When it comes time for them to set up a proper account (e.g. email-password auth) you can use the built-in user account linking feature to associate all of their anonymous activity with their account.

Thank you very much for the response!

I thought about this. Do I then just store their account data in their user custom data?

Because I don’t know how I can distinguish anonym users.

Maybe I’m paranoid but for safety I split the users data between 3 collections.

One that only the server can read and write. For stored purchases, account status etc. .

One for private user data that only the owner can read and write. Like friend lists.

And one for public user data. Like for the public user profile.

Is this bad? Should I just store everything in the custom user data and just modify the field rights?