Support the ongoing development of Laravel.io →
Authentication
Last updated 2 years ago.
0

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.

0

Thanks, that explains it. I've just got to come up with a solution.

0

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 :(.

0

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.

0

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.

0

I have this problem too. There is no way to run middleware before route file? Please help :-(

0

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!

0

Sign in to participate in this thread!

Eventy

Your banner here too?

Knappster knappster Joined 20 Feb 2015

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.