Please include the following information in your post:
- Which SDK this is regarding: nextjs-auth0
- SDK Version: 1.9.1
- Platform Version: N/A
- Code Snippets/Error Messages/Supporting Details/Screenshots:
Hi,
I am struggling a bit with the process of using roles and permissions with auth0 . The desired outcome would be to have my roles and/or permissions added to my user on the useUser()
hook from the nextjs-auth0
library.
Right now,
- I have an API with RBAC enabled;
- Created roles and permissions;
- Assigned a role to my user;
- Connected the APIs to each other;
- And created this Login flow
exports.onExecutePostLogin = async (event, api) => {
const namespace = 'https://__________.auth0.com';
if (event.authorization) {
api.idToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
api.accessToken.setCustomClaim(`${namespace}/roles`, event.authorization.roles);
}
};
But it does not show up when using getting my user. I created a “dummy” Login flow which adds the foobar: foobar2
bit that shows on my screenshot (...setCustomClaim("foobar", "foobar2")
). I am not sure what I am missing here. The goal is to have the roles and permission to conditional rendering UI elements and afterword inside pages/api
for proctecting certain actions.
Am I missing an important step?
Thanks.