From 8b0f5f340720ad58a1b50d4a08100efc2999abb4 Mon Sep 17 00:00:00 2001 From: Marco Date: Mon, 1 Apr 2024 09:37:38 +0200 Subject: [PATCH] Add tests for 'Auth#prepareTwoFactorViaTotp' --- tests/index.php | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tests/index.php b/tests/index.php index 5d48bbe..7ee41de 100644 --- a/tests/index.php +++ b/tests/index.php @@ -350,6 +350,22 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'too many requests'; } } + else if ($_POST['action'] === 'prepareTwoFactorViaTotp') { + try { + $keyUriAndSecret = $auth->prepareTwoFactorViaTotp($_POST['serviceName']); + + return \implode(' | ', $keyUriAndSecret); + } + 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'; @@ -878,6 +894,12 @@ function showAuthenticatedUserForm(\Delight\Auth\Auth $auth) { echo ''; echo ''; + echo '
'; + echo ''; + echo ' '; + echo ''; + echo '
'; + echo '
'; echo ''; echo '';