php - No logged in user in Authenticate middleware but in other Middlewares -
introduction
problem is, have no logged in user when trying use auth
middleware restrict route logged in users have 1 when getting redirected login page.
details
let's assume have these 2 routes
route web middleware
$router->group(['middleware' => 'web'], function($router) { /** @var registrar $router */ $router->get('/', ['as' => 'home', 'uses' => 'homecontroller@index']); });
route auth middleware
$router->group(['middleware' => 'auth'], function($router) { $router->get('/listings', ['as' => 'listings', 'uses' => 'listingcontroller@index']); });
the first route works without problems, second route redirects me login page. should done, when have no logged in user, logged in before! weird.
when add these 2 lines of code handle
function of middleware
illuminate\cookie\middleware\addqueuedcookiestoresponse
used in web
group
$user = \auth::user(); dd($user);
i'm getting dump of logged in user object. however, when adding lines in feedparser\http\middleware\authenticate
middleware i'm getting null
dump. how can be, user logged in in 1 middleware, not in other? need make work again? or better: more information need me solve problems
updates
if asks more information or more code post here
i imagine happened after upgrading 5.2?
i believe route should include both web
, auth
middleware, such as:
route::group(['middleware' => ['web', 'auth']], function() { route::get('home', 'homecontroller@dashboard')->name('home'); });
Comments
Post a Comment