This is because when registering the routes, the middleware hasn't yet run so Auth::check()
is always going to be false because Laravel hasn't authenticated the user at that point.
I tried creating a before middleware in an attempt to Auth before the request but same result. I get no Auth'ed user in the route group callback :(.
I don't suppose anyone has any ideas on how to access the auth'ed user within a route group? This is a massive show stopper on my migration from L4.2 to L5.
For those interested, I still couldn't find a way of getting the auth'ed user in the route group so I've made my own middleware applied to the route group.
The route group now creates all available routes defined by my permissions table and the middleware checks if the user has permission to a route inside the group, if not it simply throws a 404.
I have this problem too. There is no way to run middleware before route file? Please help :-(
iWader said:
This is because when registering the routes, the middleware hasn't yet run so
Auth::check()
is always going to be false because Laravel hasn't authenticated the user at that point.
Woaw, knowing thouroughly the life cycle pays off!
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community