diff --git a/tests/index.php b/tests/index.php index 3b2f799..5d48bbe 100644 --- a/tests/index.php +++ b/tests/index.php @@ -88,6 +88,21 @@ function processRequestData(\Delight\Auth\Auth $auth) { catch (\Delight\Auth\EmailNotVerifiedException $e) { return 'email address not verified'; } + catch (\Delight\Auth\SecondFactorRequiredException $e) { + $secondFactorOptions = []; + + if ($e->hasTotpOption()) { + $secondFactorOptions[] = 'TOTP'; + } + if ($e->hasSmsOption()) { + $secondFactorOptions[] = 'SMS (' . $e->getSmsRecipient() . ') with ' . $e->getSmsOtpValue(); + } + if ($e->hasEmailOption()) { + $secondFactorOptions[] = 'email (' . $e->getEmailRecipient() . ') with ' . $e->getEmailOtpValue(); + } + + return 'second factor required: ' . \implode(' / ', $secondFactorOptions); + } catch (\Delight\Auth\TooManyRequestsException $e) { return 'too many requests'; } @@ -167,6 +182,21 @@ function processRequestData(\Delight\Auth\Auth $auth) { catch (\Delight\Auth\UserAlreadyExistsException $e) { return 'email address already exists'; } + catch (\Delight\Auth\SecondFactorRequiredException $e) { + $secondFactorOptions = []; + + if ($e->hasTotpOption()) { + $secondFactorOptions[] = 'TOTP'; + } + if ($e->hasSmsOption()) { + $secondFactorOptions[] = 'SMS (' . $e->getSmsRecipient() . ') with ' . $e->getSmsOtpValue(); + } + if ($e->hasEmailOption()) { + $secondFactorOptions[] = 'email (' . $e->getEmailRecipient() . ') with ' . $e->getEmailOtpValue(); + } + + return 'second factor required: ' . \implode(' / ', $secondFactorOptions); + } catch (\Delight\Auth\TooManyRequestsException $e) { return 'too many requests'; } @@ -282,6 +312,21 @@ function processRequestData(\Delight\Auth\Auth $auth) { catch (\Delight\Auth\InvalidPasswordException $e) { return 'invalid password'; } + catch (\Delight\Auth\SecondFactorRequiredException $e) { + $secondFactorOptions = []; + + if ($e->hasTotpOption()) { + $secondFactorOptions[] = 'TOTP'; + } + if ($e->hasSmsOption()) { + $secondFactorOptions[] = 'SMS (' . $e->getSmsRecipient() . ') with ' . $e->getSmsOtpValue(); + } + if ($e->hasEmailOption()) { + $secondFactorOptions[] = 'email (' . $e->getEmailRecipient() . ') with ' . $e->getEmailOtpValue(); + } + + return 'second factor required: ' . \implode(' / ', $secondFactorOptions); + } catch (\Delight\Auth\TooManyRequestsException $e) { return 'too many requests'; }