Support the ongoing development of Laravel.io →
Authorization Authentication Architecture
Last updated by @ajax30 2 years ago.
0

You have to define your route like this

Route::get('/users', [UsersContoller::class, 'index'])->middleware('checkUserPermissions:view-users');

And you have to update your middleware handle function to

public function handle(Request $request, Closure $next, $permission)
    {
        // Check user permissions
        if (!$this->hasPermissionTo($permission)) {
            return redirect('/')->with('error', 'You do not have permission to access to this section of the application');
        }
        return $next($request);
}

Hope, this will help you.

Last updated by @faisal 2 years ago.
0

Sign in to participate in this thread!

Eventy

Your banner here too?

Razvan ajax30 Joined 2 Oct 2021

Moderators

We'd like to thank these amazing companies for supporting us

Your logo here?

Laravel.io

The Laravel portal for problem solving, knowledge sharing and community building.

© 2024 Laravel.io - All rights reserved.