There doesn’t seems to be anyway to test authEvents but anyway, the same provided code works on fb login and email/password trigger.
However, when you use custom JWT token, the trigger gets called (as reflected in the stitch app log), but it doesn’t insert data into collection. It doesn’t create a new document at all.
exports = function(authEvent){
if (authEvent.operationType !== "CREATE") { return }
const { user } = authEvent;
const users = context.services.get("atlas")
.db("database")
.collection("collection");
const isLinkedUser = user.identities.length > 1;
if(isLinkedUser) {
const { identities } = user;
return users.updateOne(
{ id: user.id },
{ $set: { identities } }
)
} else {
return users.insertOne({ _id: user.id, ...user })
.catch(console.error)
}
};