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

return $authenticator->makeRequestOneTimePasswordResponse();
}
}