Prepare 2FA
This commit is contained in:
parent
63ca2a209d
commit
6d890aaf7f
11 changed files with 135 additions and 10 deletions
32
app/Http/Middleware/TwoFactorAuth.php
Normal file
32
app/Http/Middleware/TwoFactorAuth.php
Normal file
|
@ -0,0 +1,32 @@
|
|||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Auth;
|
||||
use Closure;
|
||||
|
||||
class TwoFactorAuth
|
||||
{
|
||||
/**
|
||||
* Handle an incoming request.
|
||||
*
|
||||
* @param \Illuminate\Http\Request $request
|
||||
* @param \Closure $next
|
||||
* @return mixed
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if($request->user()) {
|
||||
$user = $request->user();
|
||||
$enabled = (bool) $user->{'2fa_enabled'};
|
||||
if($enabled != false) {
|
||||
$checkpoint = 'i/auth/checkpoint';
|
||||
if($request->session()->has('2fa.session.active') !== true && !$request->is($checkpoint))
|
||||
{
|
||||
return redirect('/i/auth/checkpoint');
|
||||
}
|
||||
}
|
||||
}
|
||||
return $next($request);
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue