diff --git a/tests/index.php b/tests/index.php index a710d0a..353c655 100644 --- a/tests/index.php +++ b/tests/index.php @@ -439,6 +439,28 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'too many requests'; } } + else if ($_POST['action'] === 'enableTwoFactorViaSms') { + try { + $recoveryCodes = $auth->enableTwoFactorViaSms($_POST['otpValue']); + + return \implode(' | ', $recoveryCodes); + } + catch (\Delight\Auth\InvalidOneTimePasswordException $e) { + return 'invalid OTP'; + } + catch (\Delight\Auth\TwoFactorMechanismNotInitializedException $e) { + return 'not initialized'; + } + catch (\Delight\Auth\TwoFactorMechanismAlreadyEnabledException $e) { + return 'already enabled'; + } + catch (\Delight\Auth\NotLoggedInException $e) { + return 'not logged in'; + } + catch (\Delight\Auth\TooManyRequestsException $e) { + return 'too many requests'; + } + } else if ($_POST['action'] === 'reconfirmPassword') { try { return $auth->reconfirmPassword($_POST['password']) ? 'correct' : 'wrong'; @@ -997,6 +1019,12 @@ function showAuthenticatedUserForm(\Delight\Auth\Auth $auth) { echo ''; echo ''; + echo '
'; + echo ''; + echo ' '; + echo ''; + echo '
'; + echo '
'; echo ''; echo '';