Can't call Auth::user() on controller's constructor
I'm trying to check if the user has permission to a certain model. Up until now (with Laravel 5.2), I added this code at the constructor:
public function __construct()
{
if (!Auth::user()->hasPermission('usergroups')) {
abort(404);
}
}
Now, after upgrading to Laravel 5.3,Auth::user() returns null when being called from the controller's constructor. If I call it within any other method of the class, it returns the currently logged in user.