You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm using this wonderful package with permissions only, as documentation is recommending to do.
app/Policies/OrderTransactionPolicy.php:
namespace App\Policies;
use App\Models\User;
use Illuminate\Auth\Access\HandlesAuthorization;
class OrderTransactionPolicy
{
use HandlesAuthorization;
/*
order policy is auto discovered by laravel
*/
public function view(User $user)
{
return ($user->can('view order transactions'));
}
}
I thought this might throw an \Spatie\Permission\Exceptions\UnauthorizedException exception.
Am I using the package correctly or why isn' this exception thrown?
I would like to implement a custom view to be rendered for this exception.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I'm using this wonderful package with
permissions
only, as documentation is recommending to do.app/Policies/OrderTransactionPolicy.php:
Inside my controller action I use:
When I try to visit a protected controller action as a user without required
view
permissions I get (debugbar):Using
dd($exception)
directly inside the Handler shows:I thought this might throw an
\Spatie\Permission\Exceptions\UnauthorizedException
exception.Am I using the package correctly or why isn' this exception thrown?
I would like to implement a custom view to be rendered for this exception.
Beta Was this translation helpful? Give feedback.
All reactions