diff --git a/src/Pages/TwoFactor.php b/src/Pages/TwoFactor.php index 08dfd7b..7a45409 100644 --- a/src/Pages/TwoFactor.php +++ b/src/Pages/TwoFactor.php @@ -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)