How to get/show rules error messages in auth0-react-samples app

Hi,

I am using auth0-react-samples and more specifically 02-Calling-an-API example code. I have it working for success scenarios and returns JWT which works with my API.

Problem: I have some rules that check for some values and based on that return a UnauthorizedError

return callback(new UnauthorizedError(
‘User has no profiles for this application.’
));

How do I get this error in SPA and show it to user?
I saw https://github.com/auth0-samples/auth0-react-samples/blob/master/02-Calling-an-API/src/react-auth0-spa.js#L26-L29 but shouldn’t auth0FromHook.handleRedirectCallback() handle it and return error obj or something.

I found React Quickstart can't parse token in handleRedirectCallback - #5 by carolin but their solution of deleting the rule don’t work for us. We want the error message so use knows they are not allowed.
Also do I have to explicitly logout this user from app, if rules failed or it happens on auth0 end?

Thanks.

2 Likes

I am working on this very issue right now. Did you ever figure that out?

Nope. We are planning to either do a MFA enrollment separate via the enrollment email or moving the error logic to application callback page.

Hey there!

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!

Learn more here!