Skip to content

Commit 12ff490

Browse files
authored
[Bug] Use can access method for pages (alexjustesen#1339)
1 parent b3a17bb commit 12ff490

File tree

7 files changed

+8
-22
lines changed

7 files changed

+8
-22
lines changed

app/Filament/Pages/Dashboard.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,6 @@ class Dashboard extends BasePage
2020
{
2121
protected static ?string $navigationIcon = 'heroicon-o-chart-bar';
2222

23-
protected static ?int $navigationSort = 1;
24-
2523
protected static string $view = 'filament.pages.dashboard';
2624

2725
protected function getHeaderActions(): array

app/Filament/Pages/Settings/GeneralPage.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,11 +26,9 @@ class GeneralPage extends SettingsPage
2626

2727
protected static string $settings = GeneralSettings::class;
2828

29-
public function mount(): void
29+
public static function canAccess(): bool
3030
{
31-
parent::mount();
32-
33-
abort_unless(auth()->user()->is_admin, 403);
31+
return auth()->user()->is_admin;
3432
}
3533

3634
public static function shouldRegisterNavigation(): bool

app/Filament/Pages/Settings/InfluxDbPage.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ class InfluxDbPage extends SettingsPage
2121

2222
protected static string $settings = InfluxDbSettings::class;
2323

24-
public function mount(): void
24+
public static function canAccess(): bool
2525
{
26-
parent::mount();
27-
28-
abort_unless(auth()->user()->is_admin, 403);
26+
return auth()->user()->is_admin;
2927
}
3028

3129
public static function shouldRegisterNavigation(): bool

app/Filament/Pages/Settings/NotificationPage.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,11 +27,9 @@ class NotificationPage extends SettingsPage
2727

2828
protected static string $settings = NotificationSettings::class;
2929

30-
public function mount(): void
30+
public static function canAccess(): bool
3131
{
32-
parent::mount();
33-
34-
abort_unless(auth()->user()->is_admin, 403);
32+
return auth()->user()->is_admin;
3533
}
3634

3735
public static function shouldRegisterNavigation(): bool

app/Filament/Pages/Settings/ThresholdsPage.php

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -21,11 +21,9 @@ class ThresholdsPage extends SettingsPage
2121

2222
protected static string $settings = ThresholdSettings::class;
2323

24-
public function mount(): void
24+
public static function canAccess(): bool
2525
{
26-
parent::mount();
27-
28-
abort_unless(auth()->user()->is_admin, 403);
26+
return auth()->user()->is_admin;
2927
}
3028

3129
public static function shouldRegisterNavigation(): bool

app/Filament/Resources/ResultResource.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,6 @@ class ResultResource extends Resource
3131

3232
protected static ?string $navigationIcon = 'heroicon-o-table-cells';
3333

34-
protected static ?int $navigationSort = 2;
35-
3634
public static function form(Form $form): Form
3735
{
3836
$settings = new GeneralSettings();

app/Filament/Resources/UserResource.php

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,6 @@ class UserResource extends Resource
2121

2222
protected static ?string $navigationIcon = 'heroicon-o-users';
2323

24-
protected static ?int $navigationSort = 3;
25-
2624
public static function form(Form $form): Form
2725
{
2826
return $form

0 commit comments

Comments
 (0)