mirror of
https://github.com/delight-im/PHP-Auth.git
synced 2025-07-10 19:16:22 +02:00
Handle 'SecondFactorRequiredException' in four relevant cases in tests
This commit is contained in:
@ -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';
|
||||
}
|
||||
|
Reference in New Issue
Block a user