Laravel-modules: Auth data is lost after login

Created on 15 Jun 2017  路  3Comments  路  Source: nWidart/laravel-modules

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?

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' ); });

All 3 comments

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.

Was this page helpful?
0 / 5 - 0 ratings