BackendAuth::getUser() return logged user when I call it from my plugin routes.php file, like in build 419
BackendAuth::getUser() return null (same behavior for Auth::getUser()).
Route::get('/test', function() {
dd(
Auth::getUser(),
BackendAuth::getUser()
);
});
/testSame behavior if you add the dump inside a CMS page but work fine from plugins onRun and init method.
I have followed the error and seems this come from the following lines
https://github.com/octobercms/library/blob/develop/src/Auth/Manager.php#L340-L345
Cookie::get() return a string instead of an array like expected by the test on line 343.
420
Add the web middleware to your route and it will work. Session handling and other related middleware components are no longer run on every single route by default in Laravel 5.5 so you need to add the web middleware to your routes for it to work. There are some related issues to this with the RainLab.Translate plugin. See https://github.com/rainlab/translate-plugin/issues/288
Thanks @LukeTowers
For those that have the same problem :
Route::get('/test', function () {
dd(
Auth::getUser(),
BackendAuth::getUser()
);
})->middleware('web');
Most helpful comment
Thanks @LukeTowers
For those that have the same problem :