Offline App User Registraion

Hello, I have the following use case: An admin user (without restrictions) goes off the grid and meets another person. The admin must create a new user for that person and also possibly create a few documents that include the new user id. Btw, I am only using the Email/password auth provider.

My attempt: From my testing registering new users through the Realm SDK - app.emailPasswordAuth.registerUser({email, password}) requires a connection to the internet (makes sense). Let me know if I am wrong. I’ve read this topic.

Different approach: I’ve set up my entire database so that any dependency on the user id is linked to the object id of the document inside my custom user data collection(collection name is users). My plan is while being offline, the admin will create a new document inside the synced users collection. Later when he comes back online the new document will sync, then it will trigger a function and inside the function, I create and confirm the actual app user.

Question 1: Is there a way to do this using the function context or is using the admin API the only way?

Question 2: Any recommendations for the use case or possible pitfalls that I am not noticing?

Hi @Damian_Danev,

Did you ever figure out an effective solution for this use case? I have the exact same requirement to create a new user while offline.

Hi @Paolo_Manna,

Following up on this thread and

Is there any way to do what Damian asked above? I know once one has initially logged in online from a client app, one can subsequently operate offline. But is there any way for a user to initially start using a client app offline, then later on, connect online?

Hi @Phil_Seeman,

When working with Device Sync, no, there isn’t, or at least not directly: Device Sync creates on the backend a reference to a user’s local snapshot, so that two-way synchronisation can transparently happen later, but if there’s no user to bind to, there can be no synchronisation.

In theory, it’s possible to detect that there’s no connection and no initial status, and create a local .realm to write temporary data into, you won’t need a user for that. When the device comes online, this local cache could then be copied into the newly created synchronised realm to upload. This process would only be used once, and only when the initial startup happens offline, thus the scenario is very limited to consider for the SDK, but if it’s a key functionality for your use case, you may choose to take the effort to implement it.

Thanks, @Paolo_Manna, that all makes sense!