Can't control access to pages using actions?

Hi @nc14,

Thanks for reaching out to the Auth0 Community!

I understand that you are trying to deny access to users who do not have an Admin role.

To do so, you will need to use a Post-Login Action to check if the authentication request comes from your application and that the user has the admin role. See below:

exports.onExecutePostLogin = async (event, api) => {
  if(event.client.name === 'YOUR_CLIENT_NAME' && event.authorization.roles !== 'admin'){
    api.access.deny(Access to ${event.client.name} is not allowed.);
  }
};

You can find your Client Name in your Auth0 Dashboard > Applications > Applications and click on your app. On the settings page, the Name should match the event.client.name.

Once this is complete, you can control and restrict access to your application.

Hoped this helps!

Please let me know if you have any further questions.

Thank you.

1 Like