dimanche 24 janvier 2016

Accessing Auth in Exceptions\Handler.php

I'm trying to access the Auth class from within the render method of the App\Exceptions\Handler class (app/Exceptions/Handler.php) to determine if the User is currently logged in, using the Auth::check() method.

This worked fine in 5.1, but I've upgraded to 5.2 and it no longer works.

To debug this, I've been printing Auth::user() to the logs (which returns NULL), then returning a redirect() to another view.

Then from the view/controller the redirect goes to, printing the same Auth::user() to the logs, which works as expected and returns the logged in user.

So it seems there's no problem accessing the Auth class or the user() method from within the Exceptions\Handler class, it's just that it returns NULL for some reason, whereas other parts of the app return the User..

Thanks for any info on this!



from Newest questions tagged laravel-5 - Stack Overflow http://ift.tt/1K5zGPf
via IFTTT

Aucun commentaire:

Enregistrer un commentaire