Answer the question
In order to leave comments, you need to log in
How to use Auth::user() in Laravel middleware when using sanctum?
Tell me, I use sanctum for authorization, I decided to add my own middleware, which should check Auth::user() However, with such a call:
Route::middleware('auth:sanctum')->middleware('activated')->group(function () {
Route::get('/name', function (Request $request) {
return response()->json(['user' => auth()->user()]);
});
});
Route::middleware('auth:sanctum')->group(function () {
Route::get('/name', function (Request $request) {
return response()->json(['user' => auth()->user()]);
})->middleware('activated');
});
protected $middlewarePriority = [
\App\Http\Middleware\Authenticate::class,
\App\Http\Middleware\CheckUserActivation::class
];
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question