Skip to content

Commit 08bf4c1

Browse files
committed
fix: go to 403 page if new user first login
1 parent 3165f75 commit 08bf4c1

3 files changed

Lines changed: 23 additions & 10 deletions

File tree

src/Facades/InspireCms.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
* @method static ?stirng version()
99
* @method static bool needInstall() Determine if there is a need to go to the install page
1010
* @method static ?string getInstallUrl()
11-
* @method static ?string getImportDataUrl(bool $authorize = true)
11+
* @method static ?string getImportDataUrl()
1212
* @method static \Illuminate\Support\Collection<\SolutionForest\InspireCms\DataTypes\Manifest\ClusterSection> getSections(... $names)
1313
* @method static void routes() Registers the routes for the Inspire CMS.
1414
* @method static void addSection(\SolutionForest\InspireCms\DataTypes\Manifest\ClusterSection $section)

src/Filament/Pages/Export.php

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010
use Filament\Infolists\Contracts\HasInfolists;
1111
use Filament\Pages\Page;
1212
use Illuminate\Contracts\Support\Htmlable;
13+
use Livewire\Attributes\Url;
1314
use SolutionForest\InspireCms\Filament\Clusters\Settings;
1415
use SolutionForest\InspireCms\Filament\Concerns\ClusterSectionPageTrait;
1516
use SolutionForest\InspireCms\Filament\Contracts\ClusterSectionPage;
@@ -32,6 +33,22 @@ class Export extends Page implements ClusterSectionPage, HasActions, HasForms, H
3233
protected static ?string $navigationIcon = 'heroicon-o-archive-box';
3334

3435
protected static ?string $cluster = Settings::class;
36+
37+
#[Url]
38+
public ?string $redirectUrl = null;
39+
40+
public function mountCanAuthorizeAccess(): void
41+
{
42+
// Overwrite the default behavior
43+
if (! static::canAccess()) {
44+
45+
if (filled($this->redirectUrl)) {
46+
redirect()->intended($this->redirectUrl);
47+
} else {
48+
abort(403);
49+
}
50+
}
51+
}
3552

3653
public static function canAccess(): bool
3754
{

src/InspireCms.php

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -75,21 +75,17 @@ public function getInstallUrl(): ?string
7575
return Filament::getPanel(InspireCmsConfig::getPanelId())?->getRegistrationUrl();
7676
}
7777

78-
public function getImportDataUrl(bool $authorize = true): ?string
78+
public function getImportDataUrl(): ?string
7979
{
8080
try {
8181

8282
$page = InspireCmsConfig::getFilamentPage('export', \SolutionForest\InspireCms\Filament\Pages\Export::class);
8383

84-
$url = UrlHelper::attemptToGetUrlFromPanel($page);
84+
$panel = Filament::getPanel(InspireCmsConfig::getPanelId());
8585

86-
if (! $authorize) {
87-
return $url;
88-
}
89-
90-
if ($authorize && is_string($page) && $page::canAccess()) {
91-
return $url;
92-
}
86+
$parameters['redirectUrl'] = $panel?->getHomeUrl();
87+
88+
return UrlHelper::attemptToGetUrlFromPanel($page, $parameters);
9389

9490
} catch (\Exception $th) {
9591
//

0 commit comments

Comments
 (0)