From 9464d754bd120e746767018377fa236de2c87ad9 Mon Sep 17 00:00:00 2001 From: Marco Date: Thu, 4 Apr 2024 19:52:29 +0200 Subject: [PATCH] Add tests for method 'Auth#prepareTwoFactorViaEmail' --- tests/index.php | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/tests/index.php b/tests/index.php index 723db3f..a710d0a 100644 --- a/tests/index.php +++ b/tests/index.php @@ -401,6 +401,22 @@ function processRequestData(\Delight\Auth\Auth $auth) { return 'too many requests'; } } + else if ($_POST['action'] === 'prepareTwoFactorViaEmail') { + try { + $emailAddressAndOtpValue = $auth->prepareTwoFactorViaEmail(); + + return $emailAddressAndOtpValue[1] . ' -> ' . $emailAddressAndOtpValue[0]; + } + 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'] === 'enableTwoFactorViaTotp') { try { $recoveryCodes = $auth->enableTwoFactorViaTotp($_POST['otpValue']); @@ -970,6 +986,11 @@ function showAuthenticatedUserForm(\Delight\Auth\Auth $auth) { echo ''; echo ''; + echo '
'; + echo ''; + echo ''; + echo '
'; + echo '
'; echo ''; echo ' ';