Skip to content

Commit

Permalink
redirect guest user to the login page of current panel, or default pa…
Browse files Browse the repository at this point in the history
…nel if current panel could not be detected. (#57)
  • Loading branch information
MarJose123 authored Aug 21, 2024
2 parents c802bfc + a388b15 commit 2d48df9
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
2 changes: 1 addition & 1 deletion routes/web.php
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
? config('filament-lockscreen.url')
: '/screen/lock',
LockerScreen::class
)->name('page')->middleware(['auth']);
)->name('page');
});

}
Expand Down
10 changes: 7 additions & 3 deletions src/Http/Livewire/LockerScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,11 +37,15 @@ class LockerScreen extends BasePage
public function mount()
{
// Check if the request is still authenticated or not before rendering the page,
// if not authenticated then redirect to the default filament login page
// if not authenticated then redirect to the login page of current panel, or default panel if current panel could not be detected.

if(!Filament::auth()->check())
if (!Filament::auth()->check())
{
return redirect(Filament::getDefaultPanel()->getLoginUrl());
if (filament()->getCurrentPanel()) {
return redirect(filament()->getCurrentPanel()->getLoginUrl());
}

return redirect(filament()->getDefaultPanel()->getLoginUrl());
}

session(['lockscreen' => true]);
Expand Down

0 comments on commit 2d48df9

Please sign in to comment.