Files
UNIT3D-Community-Edition/app/Http/Middleware/CheckIfBanned.php
HDVinnie 4efd2d207a (Update) Refactoring
- autoBan
- LoginController
- Middleware
- Routes
2018-02-14 15:11:17 -05:00

40 lines
1004 B
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 \Toastr;
class CheckIfBanned
{
/**
* Handle an incoming request.
*
* @param \Illuminate\Http\Request $request
* @param \Closure $next
* @param string|null $guard
* @return mixed
*/
public function handle($request, Closure $next, $guard = null)
{
$user = auth()->user();
if ($user and $user->group_id == 5) {
auth()->logout();
$request->session()->flush();
return redirect('login')->with(Toastr::error('This account is Banned!', 'Whoops!', ['options']));
}
return $next($request);
}
}