Skip to content

Commit

Permalink
[Fix] use object instead of unexisting user model
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Aug 23, 2024
1 parent 940aca6 commit f1227fb
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 10 deletions.
5 changes: 2 additions & 3 deletions src/Http/Livewire/Auth/LoginTwoFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
{
Expand Down Expand Up @@ -97,4 +96,4 @@ protected function getFormSchema(): array

];
}
}
}
10 changes: 6 additions & 4 deletions src/Listeners/SendTwoFactorCodeListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand All @@ -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));
}
}
}
5 changes: 2 additions & 3 deletions src/Notifications/SendOTP.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -83,4 +82,4 @@ public function getTwoFactorCode(User $notifiable): ?string
decrypt($notifiable->two_factor_secret)
);
}
}
}

0 comments on commit f1227fb

Please sign in to comment.