mirror of
https://github.com/zoe-may/TDoG-Skin.git
synced 2025-01-19 10:17:24 +08:00
26 lines
550 B
PHP
26 lines
550 B
PHP
|
<?php
|
||
|
|
||
|
namespace App\Http\Middleware;
|
||
|
|
||
|
use App\Models\User;
|
||
|
use Closure;
|
||
|
|
||
|
class RejectBannedUser
|
||
|
{
|
||
|
public function handle($request, Closure $next)
|
||
|
{
|
||
|
if ($request->user()->permission == User::BANNED) {
|
||
|
if ($request->expectsJson()) {
|
||
|
$response = json(trans('auth.check.banned'), -1);
|
||
|
$response->setStatusCode(403);
|
||
|
|
||
|
return $response;
|
||
|
} else {
|
||
|
abort(403, trans('auth.check.banned'));
|
||
|
}
|
||
|
}
|
||
|
|
||
|
return $next($request);
|
||
|
}
|
||
|
}
|