Hi, I’m trying to assign roles for users who have signed up to our site via Netlify Identity with the use of serverless functions. I’ve followed the guide here. It’s a bit hard to follow and I’m still a beginner in JS, but I’ve basically used the same code from the blog:
exports.handler = function(event, context, callback) {
const data = JSON.parse(event.body);
const { user } = data;
const responseBody = {
app_metadata: {
roles: ["authorized"]
},
user_metadata: {
...user.user_metadata, // append current user metadata
}
};
callback(null, {
statusCode: 200,
body: JSON.stringify(responseBody)
});
};
When I build the site, I can see functions are being built, assuming everything is going as expected. But after inviting myself and signing up, my account has no roles, and I was expecting it to be “Authorized”.
I’d love to learn more on setting this up, with future plans on automating it based off user’s email addresses as well. I’d appreciate any guidance on this issue!