Skip to content

Commit

Permalink
improve recovery code sync using vanilla javascript instead of livewire
Browse files Browse the repository at this point in the history
  • Loading branch information
markvaneijk committed Oct 22, 2024
1 parent 8dce33f commit 38a0dcd
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/Http/Livewire/Auth/LoginTwoFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,6 @@ class LoginTwoFactor extends Page implements HasActions, HasForms

public ?string $code = null;

public ?string $recovery_code = null;

#[Reactive]
public int $lastResendTime = 0;

Expand Down Expand Up @@ -73,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 @@ -135,9 +133,8 @@ protected function getFormSchema(): array
->extraInputAttributes([
'name' => 'code',
'autocomplete' => 'one-time-code',
])
->afterStateUpdated(fn (Set $set, ?string $state) => $set('recovery_code', $state))
->live(),
'onchange' => 'document.getElementById("recovery_code").value = this.value'
]),
];
}
}

0 comments on commit 38a0dcd

Please sign in to comment.