New User Sync Questions

  1. When creating a user (email/password) through the Atlas UI, I noticed the User Creation Function does not get called (this is where I insert a record into the users collection). It does get called if the user creation happens through the swift sdk. Is this expected?

  2. In working around the above issue, I moved the User Creation code to a Log In Trigger. Sync Service Rules seem to be determined before the trigger happens. When I open the realm I am getting errors because the data needed in custom_data does not exist. If restart the swift app, it works fine. Again, this only happens the first time if a user does not have a record defined in the users table.

  3. Below is my Read Document Permissions assigned to a collection. When there is no user record, it throws an error … “state_Account”: (BadValue) $in needs an array. Is there anyway to write this rule so I can handle a case when accountIds does not exist (return no records and not throw an error).

  "_id": {
    "$in": "%%user.custom_data.accountIds"
  1. yes, this is expected. the function only fires for programmatic access
  2. i would leave the user creation as a user creation function, and create users via an sdk, rather than creating them via the atlas ui
  3. we are actually working on a fix for this now and should have this issue resolved in the coming weeks. However, if you were to reinstate your user creation function, you could always create the custom user data with an empty array to avoid this error.

I am having a similar issue, I am not able to get the new user function to fire when I add a user via the UI or the .Net SDK. I have tested running the function directly with in the Function UI and it works and created my User custom document. I am currenlty using Username/Password auth provider. I also have noticed that the new user does not automatically confirm as I have configured in the provider setup. Any suggestions?