From 0f71c335e66140ede24e31108ebeaca8dc05e9b7 Mon Sep 17 00:00:00 2001 From: Marco Date: Tue, 11 Jun 2024 11:12:04 +0200 Subject: [PATCH] Implement 'enableTwoFactorViaSms' using 'enableTwoFactor' --- src/Auth.php | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/Auth.php b/src/Auth.php index 63a1963..8272e7a 100644 --- a/src/Auth.php +++ b/src/Auth.php @@ -1940,6 +1940,26 @@ final class Auth extends UserManager { return $this->enableTwoFactor(self::TWO_FACTOR_MECHANISM_TOTP, $otpValue); } + /** + * Completes the previously started setup of two-factor authentification with one-time passwords sent via SMS + * + * Initially providing a valid one-time password here once is what proves that the setup was successful on the client side + * + * In order to let the user set up their phone number for OTPs via SMS, call {@see prepareTwoFactorViaSms} as a first step + * + * @param string $otpValue a one-time password (OTP) that has just been entered by the user + * @return string[] a few recovery codes that can be used instead of one-time passwords from text messages in case the user loses access to their phone (number) + * @throws InvalidOneTimePasswordException if the one-time password provided by the user is not valid + * @throws TwoFactorMechanismNotInitializedException if this method of two-factor authentification has not been initialized before or if the initialization has expired + * @throws TwoFactorMechanismAlreadyEnabledException if this method of two-factor authentification has already been enabled + * @throws NotLoggedInException if the user is not currently signed in + * @throws TooManyRequestsException if the number of allowed attempts/requests has been exceeded + * @throws AuthError if an internal problem occurred (do *not* catch) + */ + public function enableTwoFactorViaSms($otpValue) { + return $this->enableTwoFactor(self::TWO_FACTOR_MECHANISM_SMS, $otpValue); + } + /** * Completes the previously started setup of two-factor authentification via a specified mechanism *