Skip to content

Commit

Permalink
feat: add validation for empty options while setting two factor auth
Browse files Browse the repository at this point in the history
  • Loading branch information
lucascnunes committed Oct 12, 2024
1 parent 817026c commit e83e413
Showing 1 changed file with 12 additions and 4 deletions.
16 changes: 12 additions & 4 deletions src/Pages/TwoFactor.php
Original file line number Diff line number Diff line change
Expand Up @@ -193,11 +193,19 @@ public function enableAction(): Action
$formData['email'] = $data['email'];
}

if ($this->twoFactorData['option']) {
$formData['two_factor_type'] = TwoFactorType::tryFrom($this->twoFactorData['option']);
}
try {
if ($this->twoFactorData['option']) {
$formData['two_factor_type'] = TwoFactorType::tryFrom($this->twoFactorData['option']);
}
} catch (\Exception $e) {
Notification::make()
->title('Error!')
->body(__('Please select a method of authentication.'))
->danger()
->send();
return;
} /** @var array{two_factor_type: TwoFactorType|null, email?: mixed} $formData */

/** @var array{two_factor_type: TwoFactorType|null, email?: mixed} $formData */
if (
isset($formData['two_factor_type']) &&
($formData['two_factor_type'] === TwoFactorType::email || $formData['two_factor_type'] === TwoFactorType::phone)
Expand Down

0 comments on commit e83e413

Please sign in to comment.