-
Notifications
You must be signed in to change notification settings - Fork 10.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[5.3] [Bug] with accessing the user. #14983
Comments
thank you for this ... having the same problem too..hope there is a solution very very soon.. T.T |
You have to change this since with Laravel 5.3 you can not access user in Controller constructors. As an alternative, you can use |
That's fine, but I want to share them in bulk. Hence, I would have to declare the share and/or the composer in a service provider. However, that doesn't work either. Plus, I just noticed that I can't do auth()->user() in a middleware as well. I hope that those changes were not intentional. |
Could you give a link to the doc where such behavior is mentioned? |
as OP stated.. i need to share stuffs in bulk too..... any alternative?? my code relies largely on some data of the auth shared in bulk..its used frigging everywhere..lol |
@tzurbaev while it's not documented it's a bug, not a feature : ) And it's a really bad change |
I had similar problem. Fix it with middleware class. Put Sentinel::check() and View::share. If I need object in controller, just get it by $request. I don't now is it good way or not, but it's working for me :) |
Hello,
I've just started experimenting with L5.3. Basically, it seems that the authentication system is not booted, when resolving a Controller. I know that there have been changes in the way Controllers are being resolved in 5.3, and I hope that is not the issue. So, here's the code.
It seems that when resolving the controller, the authentication system doesn't recognize the user. Hence, the
auth()->guard('admin')->user()
returns null.But, if I use the same code inside my blade, it works. Consequently, that means that the authentication system gets registered/booted once we start resolving the views.
If you wonder, whether I have something weird going on with my service providers, here's an excerpt of my app.php file:
I tried moving things around, but nothing seemed to work.
Thanks in advance!
The text was updated successfully, but these errors were encountered: