I'm using Laravel 7 and appzcoder/laravel-admin package. my system is already pretty extensive and I have been able to work with authentication, authorization, roles and permissions fine so far. Today when my users try to do an action and they don't have authorization for it laravel gates and polices throw an unathorized exception and redirect them to a 403 not authorized page.
What I wish was that everytime my users don't have permission, laravel redirected them back with a message. How can I do that?
Remembering that My Guards and Polices are auto-generated with my permissions table rows as per appzcoder/laravel-admin functionality.
This may be the problem of
CSRFtokenCSRFis enabled by default on all Routes in Laravel > 5, you can disable it for specific routes by modifying app/Http/Middleware/VerifyCsrfToken.phpplace all your unauthorized routes in this file seperated by comma.
example :