Skip to content

Commit 7bb5d0b

Browse files
authored
Merge pull request #732 from m3ue/feature-user-auth
Implement user authentication
2 parents 8e47523 + b03b4c9 commit 7bb5d0b

File tree

19 files changed

+241
-2
lines changed

19 files changed

+241
-2
lines changed

app/Filament/Pages/M3uProxyStreamMonitor.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,7 @@ class M3uProxyStreamMonitor extends Page
3232
*/
3333
public static function canAccess(): bool
3434
{
35-
return true; // Allow all users to access the stream monitor
36-
// return auth()->check() && auth()->user()->isAdmin();
35+
return auth()->check() && auth()->user()->canUseProxy();
3736
}
3837

3938
protected static string|\UnitEnum|null $navigationGroup = 'Proxy';

app/Filament/Resources/CustomPlaylists/CustomPlaylistResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,7 @@ public static function table(Table $table): Table
138138

139139
return $state;
140140
})
141+
->hidden(fn () => ! auth()->user()->canUseProxy())
141142
->sortable(),
142143
TextColumn::make('created_at')
143144
->dateTime()
@@ -321,6 +322,7 @@ public static function getForm($creating = false): array
321322
->collapsible()
322323
->collapsed($creating)
323324
->columns(2)
325+
->hidden(fn () => ! auth()->user()->canUseProxy())
324326
->schema([
325327
Toggle::make('enable_proxy')
326328
->label('Enable Stream Proxy')

app/Filament/Resources/MediaServerIntegrations/MediaServerIntegrationResource.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,15 @@ class MediaServerIntegrationResource extends Resource
6262

6363
protected static ?int $navigationSort = 100;
6464

65+
/**
66+
* Check if the user can access this page.
67+
* Only users with the "integrations" permission can access this page.
68+
*/
69+
public static function canAccess(): bool
70+
{
71+
return auth()->check() && auth()->user()->canUseIntegrations();
72+
}
73+
6574
public static function getRecordTitle(?Model $record): string|null|Htmlable
6675
{
6776
return $record?->name;

app/Filament/Resources/MergedPlaylists/MergedPlaylistResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -114,6 +114,7 @@ public static function table(Table $table): Table
114114
->label('Proxy')
115115
->toggleable()
116116
->tooltip('Toggle proxy status')
117+
->hidden(fn () => ! auth()->user()->canUseProxy())
117118
->sortable(),
118119
TextColumn::make('created_at')
119120
->dateTime()
@@ -285,6 +286,7 @@ public static function getForm($creating = false): array
285286
->collapsible()
286287
->collapsed($creating)
287288
->columns(2)
289+
->hidden(fn () => ! auth()->user()->canUseProxy())
288290
->schema([
289291
Toggle::make('enable_proxy')
290292
->label('Enable Stream Proxy')

app/Filament/Resources/Networks/NetworkResource.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,15 @@ class NetworkResource extends Resource
6060

6161
protected static ?int $navigationSort = 110;
6262

63+
/**
64+
* Check if the user can access this page.
65+
* Only users with the "integrations" permission can access this page.
66+
*/
67+
public static function canAccess(): bool
68+
{
69+
return auth()->check() && auth()->user()->canUseIntegrations();
70+
}
71+
6372
public static function getDescription(): ?string
6473
{
6574
return 'Networks are your own personal TV station that contain your lineups (local media content). Create custom broadcast channels with scheduled programming from your media library.';

app/Filament/Resources/PersonalAccessTokens/PersonalAccessTokenResource.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,15 @@ class PersonalAccessTokenResource extends Resource
2424

2525
protected static ?string $recordTitleAttribute = 'name';
2626

27+
/**
28+
* Check if the user can access this page.
29+
* Only users with the "tools" permission can access this page.
30+
*/
31+
public static function canAccess(): bool
32+
{
33+
return auth()->check() && auth()->user()->canUseTools();
34+
}
35+
2736
public static function getGloballySearchableAttributes(): array
2837
{
2938
return ['name', 'abilities'];

app/Filament/Resources/PlaylistAliases/PlaylistAliasResource.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -355,6 +355,7 @@ public static function getForm(): array
355355

356356
Schemas\Components\Fieldset::make('Proxy Options')
357357
->columns(2)
358+
->hidden(fn () => ! auth()->user()->canUseProxy())
358359
->schema([
359360
Forms\Components\Toggle::make('enable_proxy')
360361
->label('Enable Stream Proxy')

app/Filament/Resources/Playlists/PlaylistResource.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -286,6 +286,7 @@ public static function setupTable(Table $table, $relationId = null): Table
286286
? 'Proxy is required when Provider Profiles are enabled'
287287
: 'Toggle proxy status')
288288
->disabled(fn (Playlist $record): bool => $record->profiles_enabled)
289+
->hidden(fn () => ! auth()->user()->canUseProxy())
289290
->sortable(),
290291
ToggleColumn::make('auto_sync')
291292
->label('Auto Sync')
@@ -2265,6 +2266,7 @@ public static function getFormSections($creating = false, $includeAuth = false):
22652266
->collapsible()
22662267
->collapsed($creating)
22672268
->columns(2)
2269+
->hidden(fn () => ! auth()->user()->canUseProxy())
22682270
->schema([
22692271
Toggle::make('enable_proxy')
22702272
->label('Enable Stream Proxy')

app/Filament/Resources/PostProcesses/PostProcessResource.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,15 @@ class PostProcessResource extends Resource
4747

4848
protected static string|\UnitEnum|null $navigationGroup = 'Tools';
4949

50+
/**
51+
* Check if the user can access this page.
52+
* Only users with the "tools" permission can access this page.
53+
*/
54+
public static function canAccess(): bool
55+
{
56+
return auth()->check() && auth()->user()->canUseTools();
57+
}
58+
5059
public static function getGloballySearchableAttributes(): array
5160
{
5261
return ['name'];

app/Filament/Resources/StreamFileSettings/StreamFileSettingResource.php

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,15 @@ class StreamFileSettingResource extends Resource
3737

3838
protected static ?string $pluralModelLabel = 'Stream File Settings';
3939

40+
/**
41+
* Check if the user can access this page.
42+
* Only users with the "stream file sync" permission can access this page.
43+
*/
44+
public static function canAccess(): bool
45+
{
46+
return auth()->check() && auth()->user()->canUseStreamFileSync();
47+
}
48+
4049
public static function getNavigationSort(): ?int
4150
{
4251
return 6;

0 commit comments

Comments
 (0)