Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
Xinecraft committed Oct 25, 2024
1 parent a859b4c commit d04ef89
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
17 changes: 10 additions & 7 deletions app/Http/Controllers/BanWardenController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down Expand Up @@ -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');
Expand Down Expand Up @@ -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',
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down
2 changes: 1 addition & 1 deletion app/Policies/PlayerPunishmentPolicy.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions app/Providers/AuthServiceProvider.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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,
];

/**
Expand Down
4 changes: 2 additions & 2 deletions resources/default/js/Pages/BanWarden/IndexPunishment.vue
Original file line number Diff line number Diff line change
Expand Up @@ -316,8 +316,8 @@ const headerRow = [
</td>

<DtRowItem class="text-center">
<span v-if="item.masked_ip_address">
{{ item.masked_ip_address }}
<span v-if="item.ip_address || item.masked_ip_address">
{{ item.ip_address || item.masked_ip_address }}
</span>
<span
v-else
Expand Down

0 comments on commit d04ef89

Please sign in to comment.