diff --git a/tests/index.php b/tests/index.php index 353c655..e4823f7 100644 --- a/tests/index.php +++ b/tests/index.php @@ -461,6 +461,28 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'too many requests'; } } + else if ($_POST['action'] === 'enableTwoFactorViaEmail') { + try { + $recoveryCodes = $auth->enableTwoFactorViaEmail($_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'; @@ -1025,6 +1047,12 @@ function showAuthenticatedUserForm(\Delight\Auth\Auth $auth) { echo ''; echo ''; + echo '
'; + echo '