From 36012c04cf96efeaeca6b3f510374912d31f03bd Mon Sep 17 00:00:00 2001 From: Marjose Date: Mon, 5 Jun 2023 12:46:22 +0800 Subject: [PATCH] fixed missing "hash" issue --- config/filament-lockscreen.php | 14 ++++++++++++++ src/Http/Livewire/LockerScreen.php | 8 ++++++-- 2 files changed, 20 insertions(+), 2 deletions(-) diff --git a/config/filament-lockscreen.php b/config/filament-lockscreen.php index 68bf486..98d9c7c 100644 --- a/config/filament-lockscreen.php +++ b/config/filament-lockscreen.php @@ -1,4 +1,7 @@ 'heroicon-s-lock-closed', + /* + | ------------------------------------------------------------------------------------------------ + | Table Column Name + | ------------------------------------------------------------------------------------------------ + | Change the table column name if your login authentication column is checking on a different field and not on the default field ('email and password') column of the table. + */ + 'table_columns' => [ + 'account_username_field' => 'email', + 'account_password_field' => 'password', + ], + /* ======================================= * if `enable_redirect_to` is TRUE then after login, it will be redirected to the route setup under `redirect_route` */ diff --git a/src/Http/Livewire/LockerScreen.php b/src/Http/Livewire/LockerScreen.php index 1d814dc..a22a190 100644 --- a/src/Http/Livewire/LockerScreen.php +++ b/src/Http/Livewire/LockerScreen.php @@ -17,6 +17,8 @@ class LockerScreen extends Component implements HasForms public ?string $password = ''; + private ?string $account_username_field, $account_password_field; + public function mount() { session(['lockscreen' => true]); @@ -42,6 +44,8 @@ protected function forceLogout() public function login() { $data = $this->form->getState(); + $this->account_password_field = config('filament-lockscreen.table_columns.account_password_field'); + $this->account_username_field = config('filament-lockscreen.table_columns.account_username_field'); /* * Rate Limit @@ -66,8 +70,8 @@ public function login() } if (! Filament::auth()->attempt([ - 'email' => Filament::auth()->user()->email, - 'password' => $data['password'] + $this->account_username_field => Filament::auth()->user()->{$this->account_username_field}, + $this->account_password_field => $data['password'] ])) { $this->addError('password', __('filament::login.messages.failed')); return null;