On login I redirected the request to a module but Auth::user() will now return null. If I redirect to a non module route Auth::user() has data.
Any idea?
Are you using that in a __construct ? The session isn't started at that time.
Upon further investigation I found out that the 'web' middleware wasn't called when using the module routes. I created a route group with middleware 'web' to make it work
Route::group( [ 'middleware' => [ 'web' ], 'prefix' => 'hris/admin', 'namespace' => 'Modules\Hris\Http\Controllers\Admin' ], function(){
Route::get( 'dashboard', 'HrisAdminController@dashboard' );
});
Ah yes, that would do it. 馃槃 Good find.
Most helpful comment
Upon further investigation I found out that the 'web' middleware wasn't called when using the module routes. I created a route group with middleware 'web' to make it work
Route::group( [ 'middleware' => [ 'web' ], 'prefix' => 'hris/admin', 'namespace' => 'Modules\Hris\Http\Controllers\Admin' ], function(){ Route::get( 'dashboard', 'HrisAdminController@dashboard' ); });