Files
UNIT3D-Community-Edition/app/Http/Middleware/TwoStepAuth.php
HDVinnie f3010a3d49 (Update) Update Middelware
- remove facade use and replace with helpers
- cleanup
2018-03-21 12:03:16 -04:00

61 lines
1.5 KiB
PHP

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