2FAuth/app/Http/Middleware/ForceLogout.php

26 lines
488 B
PHP

<?php
namespace App\Http\Middleware;
use Closure;
use Illuminate\Support\Facades\Auth;
class ForceLogout
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param string $guards
* @return mixed
*/
public function handle($request, Closure $next, ...$guards)
{
if (Auth::user() != null) {
Auth::guard('web-guard')->logoutCurrentDevice();
}
return $next($request);
}
}