Skip to content

Commit

Permalink
[Fix] Set default two_factor_type to email when not set (#78)
Browse files Browse the repository at this point in the history
* Set default two_factor_type to email when not set

* Fix styling

---------

Co-authored-by: Baspa <10845460+Baspa@users.noreply.github.com>
  • Loading branch information
Baspa and Baspa authored Jan 21, 2025
1 parent e4781b5 commit 1b8d746
Showing 1 changed file with 2 additions and 3 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 @@ -9,14 +9,14 @@
use Filament\Forms\Components\TextInput;
use Filament\Forms\Concerns\InteractsWithForms;
use Filament\Forms\Contracts\HasForms;
use Filament\Forms\Set;
use Filament\Notifications\Notification;
use Filament\Pages\Concerns\InteractsWithFormActions;
use Filament\Pages\Page;
use Illuminate\Support\Facades\Cache;
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 +44,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 Down

0 comments on commit 1b8d746

Please sign in to comment.