I've upgraded from 5.2 -> 5.3 and the Auth::user() is returning null.
Route
Route::group(['middleware' => ['auth']], function () { Route::get('/test', 'MyController@showMain'); } Controller with constructor calling Auth::check() returns null
public $user; public function __construct() { $this->user = Auth::user(); } public function showMain() { return $this->user; } Controller with showMain calling Auth::check() returns User (as expected).
public function __construct() { // Nothing } public function showMain() { return Auth::user(); } I've also looked at the difference between a clean install of 5.3 and 5.2->5.3 upgraded. There are 2 extra classes in 5.3 that are not in the upgraded version.
- Authenticate.php
- Authorize.php
And these classes are being called by the Kernel.php in protected $routeMiddelware
I've also looked into \Auth::user() is null in 5.3.6?, not only this doesn't solve my specific problem, I also don't think it's a good solution.
Can someone explain to me why am I running into this problem?