Answer the question
In order to leave comments, you need to log in
What is the stage of user authentication in Laravel?
I'm trying to write some conditions for an authorized user, such as access rights to the controller. I am writing a check in the controller constructor, but when debugging, I notice that $request->user() === null. Thus already in an executable method everything sees. How to describe these conditions for the entire controller without adding this condition in each method?
Answer the question
In order to leave comments, you need to log in
In the constructor, you can get it only through an intermediary.
$this->middleware(function ($request, $next)
{
$this->user= Auth::user();
return $next($request);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question