In the Auth0 dashboard, I made sure to update the app_metadata for that particular user to include { moderator: true }. And I read in the docs that I’m supposed to create a rule (Auth0 Rules).
I took the example rule Move User Metadata Attributes To Profile Root Attributes and changed the references to user_metadata to app_metadata, but couldn’t get it to work.
What am I missing? Is there another easy way to update the profile payload with custom user attributes like the users’s moderator status?
Then I was trying to figure out how to get at the ID token, so I looked at Auth0.js v9 Reference and changed this bit in my code:
export function Auth0Provider({ children }) {
domain: process.env.REACT_APP_DOMAIN,
client_id: process.env.REACT_APP_clientId,
redirect_uri: window.location.origin,
+ response_type: "id_token",
});
setAuth0Client(auth0);
(I am using import createAuth0Client from "@auth0/auth0-spa-js";)
But when I restarted the app and went to localhost:8888, I didn’t see the new moderator status in the profile response. Does anyone know what I’m doing wrong?
Maybe something related an active session? Rules only execute on login events … though even a silent auth0 will trigger rules so that’s probably not the issue. Still, you could call logout to make sure your session is terminated.
I’m not certain why it isn’t working, but I wanted to provide some feedback. The lines:
just check for the presence of app_metadata and uuid. There’s probably a better way to do this in javascript (I’m not a javascript expert), but you would want the second line to be:
Also the namespace doesn’t need to be the URL of your app. By convention we use a URL, but it does not need to be a resolvable address. For example, we use https://sso.ourcompany.com/claims, even though sso.ourcompany.com is not a resolvable address.
As this topic is related to Rules - Hooks - Actions and Rules & Hooks are being deprecated soon I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!