2020-06-26 23:32:33 +00:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Http\Middleware;
|
|
|
|
|
|
|
|
use Closure;
|
|
|
|
use Illuminate\Support\Facades\Auth;
|
|
|
|
use Illuminate\Support\Facades\View;
|
|
|
|
|
|
|
|
class Bancheck
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* Handle an incoming request.
|
|
|
|
*
|
|
|
|
* @param \Illuminate\Http\Request $request
|
|
|
|
* @param \Closure $next
|
|
|
|
* @return mixed
|
|
|
|
*/
|
|
|
|
public function handle($request, Closure $next)
|
|
|
|
{
|
|
|
|
$userIP = $request->ip();
|
|
|
|
$anonymousUser = User::where('ipAddress', $userIP)->get();
|
|
|
|
|
2020-10-21 00:29:50 +00:00
|
|
|
|
|
|
|
if (Auth::check() && Auth::user()->isBanned())
|
|
|
|
{
|
2020-06-26 23:32:33 +00:00
|
|
|
View::share('isBanned', true);
|
2020-10-21 00:29:50 +00:00
|
|
|
}
|
|
|
|
elseif(!$anonymousUser->isEmpty() && User::find($anonymousUser->id)->isBanned())
|
|
|
|
{
|
2020-06-26 23:32:33 +00:00
|
|
|
View::share('isBanned', true);
|
2020-10-21 00:29:50 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-06-26 23:32:33 +00:00
|
|
|
View::share('isBanned', false);
|
|
|
|
}
|
|
|
|
|
|
|
|
return $next($request);
|
|
|
|
}
|
|
|
|
}
|