It’s possible. You might have to change up your signup flow though. You can create a Netlify function called identity-signup.js
and it will run automatically every time a user signs up via Netlify Identity. So, the ideal flow would be that a user enters their payment information via Mollie (or however your current payment flow is) and then you store that data wherever you need to. Then, after there has been a successful payment, take them to a user creation flow via Netlify Identity. Once they’ve signed up, it will run the identity-signup.js
function and you can set a role for that user by returning a response in the function like so:
const responseBody = {
app_metadata: {
authorization: { roles: ["admin", "editor", "whatever_role_you_want"] }
},
};
return {
statusCode: 200,
body: JSON.stringify(responseBody),
};
In the end, you will have a user that has made a successful payment and has the role set in Netlify Identity. Next, you’ll just set your access control configs in your _redirects
or netlify.toml
file like so: /admin/* 200! Role=admin,editor