Realm Auth Trigger not firing from frontend

Hello,

I have a trigger set up to run a function on “Create” with authentication. This function creates a document in my members collection to contain some basic info about the user. The function looks like this:

  exports = function(authEvent){
  // Only run if this event is for a newly created user.
  if (authEvent.operationType !== "CREATE") { return }
  // Get the internal `user` document
  const { user } = authEvent;
  const users = context.services.get("mongodb-atlas")
    .db("MyApp")
    .collection("members");
  const isLinkedUser = user.identities.length > 1;
  if(isLinkedUser) {
    const { identities } = user;
    return users.updateOne(
      { user_id: user.id },
      { $set: { 
        email: user.data.email
      } }
    )
  } else {
    return users.insertOne({ _id: user.id, email: user.data.email })
     .catch(console.error)
  }
};

This trigger works correctly if I manually create the user in the ui, but if I create it from the front end it does not fire. The user is created, but the trigger never fires. Here is the trigger:

Any ideas why it may be failing to trigger?

Ok, so the trigger only fires after the user is confirmed through the email confirmation function and successful login. Would be helpful to include this in the documentation

1 Like

I have a similar issue.
I have a collection Products and a Trigger to fire on any Products update.
If I update Products on Compass for instance the Trigger is fired and everything works fine. However, i am using an incoming webhook (third party services - http) to do updates to the Products collection and when Products are updated from that webhook then the Trigger doesn’t fire anymore. I have tried several Authentication options for the function to be triggered but still no luck.
The funny thing is that when I first completed my job yesterday it was working and since last night it is just not working anymore. This is critical in my processes so if anybody can Help I will be more than happy.
Attached the setup of the Trigger and the Function.
Thanks!!