From f1227fbfce07ffb6bde7bdbffca964a90618cd13 Mon Sep 17 00:00:00 2001 From: Baspa Date: Fri, 23 Aug 2024 10:55:27 +0200 Subject: [PATCH] [Fix] use object instead of unexisting user model --- src/Http/Livewire/Auth/LoginTwoFactor.php | 5 ++--- src/Listeners/SendTwoFactorCodeListener.php | 10 ++++++---- src/Notifications/SendOTP.php | 5 ++--- 3 files changed, 10 insertions(+), 10 deletions(-) diff --git a/src/Http/Livewire/Auth/LoginTwoFactor.php b/src/Http/Livewire/Auth/LoginTwoFactor.php index 05af7dd..a8d33e5 100644 --- a/src/Http/Livewire/Auth/LoginTwoFactor.php +++ b/src/Http/Livewire/Auth/LoginTwoFactor.php @@ -2,7 +2,6 @@ namespace Vormkracht10\TwoFactorAuth\Http\Livewire\Auth; -use App\Models\User; use DanHarrin\LivewireRateLimiting\Exceptions\TooManyRequestsException; use DanHarrin\LivewireRateLimiting\WithRateLimiting; use Filament\Actions\Action; @@ -28,7 +27,7 @@ class LoginTwoFactor extends Page implements HasActions, HasForms protected static bool $shouldRegisterNavigation = false; - public ?User $challengedUser = null; + public ?object $challengedUser = null; public function mount(TwoFactorLoginRequest $request): void { @@ -97,4 +96,4 @@ protected function getFormSchema(): array ]; } -} +} \ No newline at end of file diff --git a/src/Listeners/SendTwoFactorCodeListener.php b/src/Listeners/SendTwoFactorCodeListener.php index 9e5d6c2..5ee360f 100644 --- a/src/Listeners/SendTwoFactorCodeListener.php +++ b/src/Listeners/SendTwoFactorCodeListener.php @@ -2,9 +2,9 @@ namespace Vormkracht10\TwoFactorAuth\Listeners; -use Laravel\Fortify\Events\TwoFactorAuthenticationChallenged; -use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled; use Vormkracht10\TwoFactorAuth\Notifications\SendOTP; +use Laravel\Fortify\Events\TwoFactorAuthenticationEnabled; +use Laravel\Fortify\Events\TwoFactorAuthenticationChallenged; class SendTwoFactorCodeListener { @@ -21,6 +21,8 @@ public function __construct() */ public function handle(TwoFactorAuthenticationChallenged | TwoFactorAuthenticationEnabled $event): void { - $event->user->notify(app(SendOTP::class)); + /** @var object $user */ + $user = $event->user; + $user->notify(app(SendOTP::class)); } -} +} \ No newline at end of file diff --git a/src/Notifications/SendOTP.php b/src/Notifications/SendOTP.php index 0192822..130075c 100644 --- a/src/Notifications/SendOTP.php +++ b/src/Notifications/SendOTP.php @@ -2,7 +2,6 @@ namespace Vormkracht10\TwoFactorAuth\Notifications; -use App\Models\User; use Illuminate\Bus\Queueable; use Illuminate\Contracts\Queue\ShouldQueue; use Illuminate\Notifications\Messages\MailMessage; @@ -73,7 +72,7 @@ public function toArray(object $notifiable): array * @throws SecretKeyTooShortException * @throws InvalidCharactersException */ - public function getTwoFactorCode(User $notifiable): ?string + public function getTwoFactorCode(object $notifiable): ?string { if (! $notifiable->two_factor_secret) { return null; @@ -83,4 +82,4 @@ public function getTwoFactorCode(User $notifiable): ?string decrypt($notifiable->two_factor_secret) ); } -} +} \ No newline at end of file