ARCANEDEV / LogViewer

:page_with_curl: Provides a log viewer for Laravel
MIT License
2.37k stars 335 forks source link

Got Error When Use role custom middleware #419

Closed ebeliejinfren closed 2 years ago

ebeliejinfren commented 2 years ago

Description:

Hi according docs when add my custom middleware it got error My Config in env : ARCANEDEV_LOGVIEWER_MIDDLEWARE=role:admin

My Middleware:

public function handle(Request $request, Closure $next , string $role)
    {
        if ($request->user()->roles()->where('name', '=', $role)->exists()) {
            return $next($request);
        }

        return redirect('/')->with('error','You have not admin access');
    }

also middelware added to routeMiddleware

Steps To Reproduce:

raul-mg commented 2 years ago

same happend to me, for unknow reason cant get user inside middleware called from the route, I test with some random route and middleware works but fail with LogViewer route conf

raul-mg commented 2 years ago

Ok, I already found my error, You just need add "web" middleware before your role middleware try this: ARCANEDEV_LOGVIEWER_MIDDLEWARE=web,role:admin

It works for me

ebeliejinfren commented 2 years ago

Ok, I already found my error, You just need add "web" middleware before your role middleware try this: ARCANEDEV_LOGVIEWER_MIDDLEWARE=web,role:admin

It works for me

it works great, thanks a lot