diff --git a/app/Http/Controllers/BanWardenController.php b/app/Http/Controllers/BanWardenController.php index b2380e57e..a7e7f42cd 100644 --- a/app/Http/Controllers/BanWardenController.php +++ b/app/Http/Controllers/BanWardenController.php @@ -20,6 +20,7 @@ class BanWardenController extends Controller public function index() { $this->authorize('viewAny', PlayerPunishment::class); + $canViewCritical = Gate::allows('viewCritical', PlayerPunishment::class); $perPage = request()->input('perPage', 10); if ($perPage > 100) { @@ -69,9 +70,11 @@ public function index() ->allowedSorts($fields) ->defaultSort('-id') ->simplePaginate(perPage: $perPage) - ->through(function ($punishment) { - return $punishment->makeHidden('ip_address'); - }) + ->through(fn($punishment) => $punishment->makeVisibleIf($canViewCritical, [ + 'ip_address', + 'plugin_punishment_id', + 'origin_server_name', + ])) ->withQueryString(); $countries = Country::select(['id', 'name'])->get()->pluck('name'); @@ -100,7 +103,7 @@ public function index() public function show(PlayerPunishment $playerPunishment, Request $request) { $this->authorize('view', $playerPunishment); - $canViewCritical = Gate::allows('viewCritical', $playerPunishment); + $canViewCritical = Gate::allows('viewCritical', PlayerPunishment::class); $playerPunishment->load([ 'country:id,name,iso_code', @@ -138,7 +141,7 @@ public function show(PlayerPunishment $playerPunishment, Request $request) public function indexLastPunishments(PlayerPunishment $playerPunishment) { $this->authorize('view', $playerPunishment); - $canViewCritical = Gate::allows('viewCritical', $playerPunishment); + $canViewCritical = Gate::allows('viewCritical', PlayerPunishment::class); $perPage = request()->query('perPage', 10); if ($perPage > 100) { @@ -185,7 +188,7 @@ public function indexLastPunishments(PlayerPunishment $playerPunishment) public function indexLastSessions(PlayerPunishment $playerPunishment) { $this->authorize('viewAnyIntel', Player::class); - $canViewCritical = Gate::allows('viewCritical', $playerPunishment); + $canViewCritical = Gate::allows('viewCritical', PlayerPunishment::class); $perPage = request()->query('perPage', 5); if ($perPage > 100) { @@ -214,7 +217,7 @@ public function indexLastSessions(PlayerPunishment $playerPunishment) public function indexAlts(PlayerPunishment $playerPunishment) { $this->authorize('viewAlts', $playerPunishment); - $canViewCritical = Gate::allows('viewCritical', $playerPunishment); + $canViewCritical = Gate::allows('viewCritical', PlayerPunishment::class); $perPage = request()->query('perPage', 5); if ($perPage > 100) { diff --git a/app/Policies/PlayerPunishmentPolicy.php b/app/Policies/PlayerPunishmentPolicy.php index 9e9943644..8324d4de3 100644 --- a/app/Policies/PlayerPunishmentPolicy.php +++ b/app/Policies/PlayerPunishmentPolicy.php @@ -68,7 +68,7 @@ public function viewAlts(User $user, PlayerPunishment $playerPunishment): bool /** * Determine whether the user can view alts of the model. */ - public function viewCritical(User $user, PlayerPunishment $playerPunishment): bool + public function viewCritical(User $user): bool { if ($user->can('read banwarden_punishments_critical')) { return true; diff --git a/app/Providers/AuthServiceProvider.php b/app/Providers/AuthServiceProvider.php index 6a30d463d..a351211f8 100644 --- a/app/Providers/AuthServiceProvider.php +++ b/app/Providers/AuthServiceProvider.php @@ -11,6 +11,7 @@ use App\Models\Download; use App\Models\FailedJob; use App\Models\News; +use App\Models\PlayerPunishment; use App\Models\Poll; use App\Models\Post; use App\Models\Rank; @@ -51,6 +52,7 @@ class AuthServiceProvider extends ServiceProvider RecruitmentSubmission::class => \App\Policies\RecruitmentSubmissionPolicy::class, FailedJob::class => \App\Policies\FailedJobPolicy::class, CommandQueue::class => \App\Policies\CommandQueuePolicy::class, + PlayerPunishment::class => \App\Policies\PlayerPunishmentPolicy::class, ]; /** diff --git a/resources/default/js/Pages/BanWarden/IndexPunishment.vue b/resources/default/js/Pages/BanWarden/IndexPunishment.vue index 4671e8dfd..746f52d49 100644 --- a/resources/default/js/Pages/BanWarden/IndexPunishment.vue +++ b/resources/default/js/Pages/BanWarden/IndexPunishment.vue @@ -316,8 +316,8 @@ const headerRow = [ - - {{ item.masked_ip_address }} + + {{ item.ip_address || item.masked_ip_address }}