Skip to content

Commit

Permalink
Set default two_factor_type to email when not set
Browse files Browse the repository at this point in the history
  • Loading branch information
Baspa committed Jan 21, 2025
1 parent e4781b5 commit eae21c0
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions src/Http/Livewire/Auth/LoginTwoFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
use Laravel\Fortify\Http\Requests\TwoFactorLoginRequest;
use Livewire\Attributes\Computed;
use Livewire\Attributes\Reactive;
use Vormkracht10\TwoFactorAuth\Enums\TwoFactorType;
use Vormkracht10\TwoFactorAuth\Notifications\SendOTP;

class LoginTwoFactor extends Page implements HasActions, HasForms
Expand Down Expand Up @@ -44,9 +45,8 @@ public function mount(TwoFactorLoginRequest $request): void
{
if ($request->challengedUser()) {
$this->challengedUser = $request->challengedUser();
$this->twoFactorType = $this->challengedUser->two_factor_type->value;
$this->twoFactorType = $this->challengedUser->two_factor_type?->value ?? TwoFactorType::email->value;

// Set initial cooldown if not already set
if (! Cache::has('resend_cooldown_' . $this->challengedUser->id)) {
Cache::put('resend_cooldown_' . $this->challengedUser->id, true, now()->addSeconds(30));
}
Expand All @@ -71,8 +71,8 @@ public function resend(): Action
->color('primary')
->extraAttributes(['class' => 'w-full text-xs'])
->link()
->disabled(fn () => ! $this->canResend())
->action(fn () => $this->handleResend());
->disabled(fn() => ! $this->canResend())
->action(fn() => $this->handleResend());
}

public function handleResend(): void
Expand Down Expand Up @@ -137,4 +137,4 @@ protected function getFormSchema(): array
]),
];
}
}
}

0 comments on commit eae21c0

Please sign in to comment.