Skip to content

Commit 0c6f7c5

Browse files
committed
fix: restore config file for guest access
1 parent 3b2cf6c commit 0c6f7c5

3 files changed

Lines changed: 23 additions & 6 deletions

File tree

config/frontend-panel.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
<?php
2+
3+
return [
4+
/*
5+
|--------------------------------------------------------------------------
6+
| Enable/disable guest access
7+
|--------------------------------------------------------------------------
8+
|
9+
| This option controls whether guests can access the frontend panel
10+
| without authentication. When enabled, users can view the panel
11+
| without needing to log in.
12+
|
13+
*/
14+
'guest_access' => (bool) env('FRONTEND_GUEST_ACCESS', true),
15+
];

src/FrontendServiceProvider.php

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ class FrontendServiceProvider extends PackageServiceProvider
1414
public function configurePackage(SpatiePackage|Package $package): void
1515
{
1616
$package->name(static::$name)
17+
->hasConfigFile()
1718
->hasTranslations()
1819
->hasViews()
1920
->hasSettings();

src/Providers/FrontendPanelProvider.php

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
use Eclipse\Core\Models\Site;
88
use Eclipse\Core\Services\Registry;
99
use Eclipse\Frontend\Filament\Pages as CustomPages;
10-
use Eclipse\Frontend\Settings\FrontendSettings;
1110
use Filament\Http\Middleware\Authenticate;
1211
use Filament\Http\Middleware\AuthenticateSession;
1312
use Filament\Http\Middleware\DisableBladeIconComponents;
@@ -35,9 +34,6 @@ class FrontendPanelProvider extends PanelProvider
3534

3635
public function panel(Panel $panel): Panel
3736
{
38-
/** @var FrontendSettings $settings */
39-
$settings = app(FrontendSettings::class);
40-
4137
$middleware = [
4238
EncryptCookies::class,
4339
AddQueuedCookiesToResponse::class,
@@ -52,7 +48,7 @@ public function panel(Panel $panel): Panel
5248
$widgets = [];
5349
$pages = [];
5450

55-
if ($settings->allow_guests) {
51+
if ($this->allowGuestAccess()) {
5652
$middleware[] = AuthenticateSession::class;
5753
$pages[] = CustomPages\Home::class;
5854
} else {
@@ -99,7 +95,7 @@ public function panel(Panel $panel): Panel
9995
EnvironmentIndicatorPlugin::make(),
10096
], app(Registry::class)->getPlugins()));
10197

102-
match ($settings->allow_guests) {
98+
match ($this->allowGuestAccess()) {
10399
true => $panel
104100
->renderHook(
105101
PanelsRenderHook::TOPBAR_END,
@@ -137,4 +133,9 @@ private static function getThemeIsolationScript(string $panelId): string
137133
});
138134
</script>";
139135
}
136+
137+
private function allowGuestAccess(): bool
138+
{
139+
return config('frontend-panel.guest_access');
140+
}
140141
}

0 commit comments

Comments
 (0)