Auth::logout()
removes user's data from current session, it does nothing to other sessions.
So you either need to somehow destroy other user's session, and I'm not sure there's a standard way to do.
Or, alternatively, mark that user for logout (in, say, an additional field in users
table), and check that mark in app/Http/Middleware/Authenticate
middleware:
public function handle($request, Closure $next)
{
if ( ( $user = $this->auth->getUser() ) && $user->forceLogout) {
$user->forceLogout = false;
$user->save();
$this->auth->logout();
}
if ($this->auth->guest())
{
if ($request->ajax())
{
return response('Unauthorized.', 401);
}
else
{
return redirect()->guest('auth/login');
}
}
return $next($request);
}
Sign in to participate in this thread!
The Laravel portal for problem solving, knowledge sharing and community building.
The community