Hello,
I’m trying to set up customData with App Service and Authentication but it doesn’t work.
I am currently on a shared mongodb, I activated in Authentication>User Setting the custom data as follows:
I have my function which is close to that of the example in the documentation :
exports = async function onUserCreation(user) {
const customUserDataCollection = context.services
.get("mongodb-atlas")
.db("kiizmi-dev")
.collection("custom_users_data");
try {
await customUserDataCollection.insertOne({
// Save the user's account ID to your configured user_id_field
userId: user.id,
// Store any other user data you want
test: user.id,
test2: 1,
role: 'default'
});
} catch (e) {
console.error(`Failed to create custom user data document for user:${user.id}`);
throw e
}
}
And which is configured with authentication system and in private.
But when I create a user (email/password) through the interface, the function doesn’t seem to run and I don’t see an insert in the collection.
When I connect with the user, his custom data is null even if I enter manually.
Thanks to anyone who takes the time to help me.