Answer the question
In order to leave comments, you need to log in
How does auth middleware work?
Good evening! I looked at the auth middleware and didn't see $next($request) there, why isn't it there? Is it possible to add an else construction where you can update the user's data. More or less like this:
if (!$request->expectsJson()) {
return route('login');
} else {
Model::where('user_id', Auth::user()->id)->update(['some' => 'value']);
}
class Authenticate extends Middleware
{
/**
* Get the path the user should be redirected to when they are not authenticated.
*
* @param \Illuminate\Http\Request $request
* @return string
*/
protected function redirectTo($request)
{
if (! $request->expectsJson()) {
return route('login');
}
}
}
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