Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

403 doesn't trigger onError event #685

Open
kratos-digital opened this issue Nov 17, 2024 · 3 comments
Open

403 doesn't trigger onError event #685

kratos-digital opened this issue Nov 17, 2024 · 3 comments

Comments

@kratos-digital
Copy link

kratos-digital commented Nov 17, 2024

I am using form requests and when an action is not authorized I return false from authorize() method in the request.

This renders the dialog with the message 403 Not authorized, but only onFinish event triggers.

The problem is when using dialogs (shadcn ui), even though the 403 dialog renders above the dialog with form, the focus is still on the dialog behind (maening you can't interact with 403 dialog until the one below is closed), and what I wanted to do with onError is to hide that dialog so the focus would be on 403.

But it seems none of the events is firing when there is any error response, other than validation errors (which returns 200 response and not an actual 422 Unprocessable Content error response). It seems onError triggers only when there is an error bag present in 200 response, and I think there is missing something to handle such response with proper events.

@wizzymore
Copy link

What i recommend to you is to handle the error in laravel's error handler and to manually set the error into the session so inertia.js will receive it, this way the onError will trigger.

@kratos-digital
Copy link
Author

I don't know what you mean. I use form request authorized method (which runs before validation) and which should return true or false, not an error or exception. Handling authorization manually would make the built-in features useless

@wizzymore
Copy link

Take a look here at this example:
https://github.com/wizzymore/inertia-errors-example

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants