Files
newznab-tmux/app/Http/Middleware/Google2FAMiddleware.php
T
2023-03-30 14:15:39 +00:00

29 lines
653 B
PHP

<?php
namespace App\Http\Middleware;
use Symfony\Component\HttpFoundation\Response;
use Illuminate\Http\Request;
use App\Support\Google2FAAuthenticator;
use Closure;
class Google2FAMiddleware
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @return mixed
*/
public function handle(Request $request, Closure $next): Response
{
$authenticator = app(Google2FAAuthenticator::class)->boot($request);
if ($authenticator->isAuthenticated()) {
return $next($request);
}
return $authenticator->makeRequestOneTimePasswordResponse();
}
}