Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🛠️ Fix(filament-lockscreen): Fix duplicate html tags #74

Merged
merged 1 commit into from
Feb 1, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
69 changes: 30 additions & 39 deletions resources/views/page/auth/login.blade.php
Original file line number Diff line number Diff line change
@@ -1,52 +1,43 @@
<div>
<x-filament-panels::layout.base :livewire="$this">
<x-filament-panels::page.simple>
@props([
'after' => null,
'heading' => null,
'subheading' => null,
])

<div class="fi-simple-layout flex min-h-screen flex-col items-center">
<div
class="fi-simple-main-ctn flex w-full flex-grow items-center justify-center"
>
<main
class="fi-simple-main my-16 w-full bg-white px-6 py-12 shadow-sm ring-1 ring-gray-950/5 dark:bg-gray-900 dark:ring-white/10 sm:max-w-lg sm:rounded-xl sm:px-12"
>
{{--Slot --}}
<div class="flex flex-row justify-center">
<img class="w-56 h-56 rounded-full" src="{{ \Filament\Facades\Filament::getUserAvatarUrl(\Filament\Facades\Filament::auth()->user())}}" alt="avatar">
</div>
<div class="flex flex-row justify-center">
<div class="font-medium dark:text-white">
<div>{{\Filament\Facades\Filament::auth()->user()?->name ?? ''}}</div>
</div>
</div>
<main>
{{--Slot --}}
<div class="flex flex-row justify-center">
<img class="w-56 h-56 rounded-full" src="{{ \Filament\Facades\Filament::getUserAvatarUrl(\Filament\Facades\Filament::auth()->user())}}" alt="avatar">
</div>
<div class="flex flex-row justify-center">
<div class="font-medium dark:text-white">
<div>{{\Filament\Facades\Filament::auth()->user()?->name ?? ''}}</div>
</div>
</div>

<x-filament-panels::form wire:submit="authenticate">
{{ $this->form }}
<x-filament-panels::form wire:submit="authenticate">
{{ $this->form }}

<x-filament-panels::form.actions
:actions="$this->getCachedFormActions()"
:full-width="$this->hasFullWidthFormActions()"
/>
</x-filament-panels::form>
<div class="text-center">
<x-filament::link>
<a class="text-primary-600 hover:text-primary-700"
href="#!"
onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
{{ __('filament-lockscreen::default.button.switch_account') }}</a>
</x-filament::link>
<form id="logout-form" action="{{ url(filament()->getLogoutUrl()) }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</div>
<x-filament-panels::form.actions
:actions="$this->getCachedFormActions()"
:full-width="$this->hasFullWidthFormActions()"
/>
</x-filament-panels::form>
<div class="text-center pt-4">
<a class="text-primary-600"
href="#!"
onclick="event.preventDefault(); document.getElementById('logout-form').submit();">
{{ __('filament-lockscreen::default.button.switch_account') }}
</a>
<form id="logout-form" action="{{ url(filament()->getLogoutUrl()) }}" method="POST" style="display: none;">
{{ csrf_field() }}
</form>
</div>


</main>
</div>
</div>
</x-filament-panels::layout.base>
</main>
</x-filament-panels::page.simple>
</div>

13 changes: 7 additions & 6 deletions src/Http/Livewire/LockerScreen.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,22 @@
use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException;
use DanHarrin\LivewireRateLimiting\WithRateLimiting;
use Filament\Actions\Action;
use Filament\Actions\ActionGroup;
use Filament\Exceptions\NoDefaultPanelSetException;
use Filament\Facades\Filament;
use Filament\Forms\Components\TextInput;
use Filament\Notifications\Notification;
use Filament\Pages\Actions\ActionGroup;
use Filament\Pages\BasePage;
use Filament\Pages\Concerns\InteractsWithFormActions;
use Filament\Pages\SimplePage;
use Psr\Container\ContainerExceptionInterface;
use Psr\Container\NotFoundExceptionInterface;

class LockerScreen extends BasePage
class LockerScreen extends SimplePage
{
use InteractsWithFormActions, WithRateLimiting;

protected bool $hasTopbar = false;

protected static ?string $title = null;

protected ?string $maxContentWidth = 'full';
Expand All @@ -43,7 +45,6 @@ public function mount()
// Check if the request is still authenticated or not before rendering the 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()->getCurrentPanel()) {
return redirect(filament()->getCurrentPanel()->getLoginUrl());
Expand All @@ -53,8 +54,8 @@ public function mount()
}

// redirect to the filament default home url if session is not locked
if (!session()->has('lockscreen')) {
return redirect(session()->has('next') ? session('next') : filament()->getDefaultPanel()->getPath());
if (! session()->has('lockscreen')) {
return redirect(session()->has('next') ? session('next') : filament()->getDefaultPanel()->getPath());
}

if (! config('filament-lockscreen.enable_redirect_to')) {
Expand Down