GlamCat's avatar

Auth middleware

Hi all!

I've got an issue with authentication middleware in Lumen. I've copied Authenticate.php from Laravel and got an error:

Fatal error: Call to undefined method Laravel\Lumen\Http\Redirector::guest() in C:\Wamp\www\lumen\app\Http\Middleware\Authenticate.php on line 42

This line has "return redirect()->guest('auth/login');", but ofc Redirector.php doesn't have this method so we have an error.

Is there any fast fix for this rather than adding guest method to this file?

0 likes
2 replies
RachidLaasri's avatar

It is not necessary, just use :

return redirect('auth/login');
GlamCat's avatar

Oh, my fault! I used "App\Http\Middleware\Authenticate::class" in "$app->middleware([", not in "$app->routeMiddleware([", so I got cyclic redirection when used something like you've suggested...

Thanks anyway!

Please or to participate in this conversation.