Files
UNIT3D-Community-Edition/app/Http/Middleware/TwoStepAuth.php
HDVinnie 7e664a667b Apply fixes from StyleCI
[ci skip] [skip ci]
2020-12-03 02:27:21 +00:00

62 lines
1.5 KiB
PHP

<?php
/**
* NOTICE OF LICENSE.
*
* UNIT3D Community Edition is open-sourced software licensed under the GNU Affero General Public License v3.0
* The details is bundled with this project in the file LICENSE.txt.
*
* @project UNIT3D Community Edition
*
* @author HDVinnie <hdinnovations@protonmail.com>
* @license https://www.gnu.org/licenses/agpl-3.0.en.html/ GNU Affero General Public License v3.0
*/
namespace App\Http\Middleware;
use App\Traits\TwoStep;
use Closure;
use Illuminate\Http\Request;
class TwoStepAuth
{
use TwoStep;
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param Closure $next
*
* @throws \Exception
*
* @return mixed
*/
public function handle(Request $request, Closure $next)
{
$response = $next($request);
$uri = $request->path();
$nextUri = \config('app.url').'/'.$uri;
$user = $request->user();
switch ($uri) {
case 'twostep/needed':
case 'password/reset':
case 'register':
case 'logout':
case 'login':
break;
default:
\session(['nextUri' => $nextUri]);
if (\config('auth.TwoStepEnabled') && $user->twostep == 1 && ! $this->twoStepVerification()) {
return \redirect()->route('verificationNeeded');
}
break;
}
return $response;
}
}