Initialer Laravel Commit für BetiX
This commit is contained in:
25
app/Http/Middleware/CheckBanned.php
Normal file
25
app/Http/Middleware/CheckBanned.php
Normal file
@@ -0,0 +1,25 @@
|
||||
<?php
|
||||
|
||||
namespace App\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Http\Request;
|
||||
use Illuminate\Support\Facades\Auth;
|
||||
use Inertia\Inertia;
|
||||
|
||||
class CheckBanned
|
||||
{
|
||||
public function handle(Request $request, Closure $next)
|
||||
{
|
||||
if (Auth::check() && Auth::user()->is_banned) {
|
||||
// Get reason
|
||||
$ban = Auth::user()->restrictions()->where('type', 'account_ban')->where('active', true)->first();
|
||||
|
||||
return Inertia::render('Errors/Banned', [
|
||||
'reason' => $ban ? $ban->reason : 'No reason provided.'
|
||||
])->toResponse($request)->setStatusCode(403);
|
||||
}
|
||||
|
||||
return $next($request);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user