0👍
✅
So after a lot of playing around this I found a temporary workaround that’s unfortunately a little ugly. I’ve inserted this into the beginning of every controller necessary.
$user = \JWTAuth::toUser(\JWTAuth::getToken());
\Auth::loginUsingID($user->id);
Then I can use the authorization policy and retrieve authenticated User Info.
0👍
For anybody coming to this Thread and using web.php Routes with ->middleware
I had the same issue that the policy wasn’t called on this line:
Route::get('/post', 'PostController@index')
->middleware('can:index, App\Post');
Problem was the space character between index, App.. after removing that it works.
Source:stackexchange.com