27 lines
583 B
PHP
27 lines
583 B
PHP
<?php
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
use Closure;
|
|
use PragmaRX\Google2FALaravel\Support\Authenticator;
|
|
|
|
class TwoFactorAuthentication
|
|
{
|
|
/**
|
|
* Handle an incoming request.
|
|
*
|
|
* @param \Illuminate\Http\Request $request
|
|
* @param \Closure $next
|
|
* @return mixed
|
|
*/
|
|
public function handle($request, Closure $next)
|
|
{
|
|
$authenticator = app(Authenticator::class)->boot($request);
|
|
|
|
if ($authenticator->isAuthenticated()) {
|
|
return $next($request);
|
|
}
|
|
|
|
return redirect()->route('2fa.authenticate');
|
|
}
|
|
}
|