1
0
mirror of https://github.com/delight-im/PHP-Auth.git synced 2025-07-10 11:06:23 +02:00

Implement 'enableTwoFactorViaEmail' using 'enableTwoFactor'

This commit is contained in:
Marco
2024-06-11 11:40:37 +02:00
parent 0f71c335e6
commit aebaea128b

View File

@ -1960,6 +1960,26 @@ final class Auth extends UserManager {
return $this->enableTwoFactor(self::TWO_FACTOR_MECHANISM_SMS, $otpValue);
}
/**
* Completes the previously started setup of two-factor authentification with one-time passwords sent via email
*
* 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 email address for OTPs via email, call {@see prepareTwoFactorViaEmail} 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 emails in case the user loses access to their email (address)
* @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 enableTwoFactorViaEmail($otpValue) {
return $this->enableTwoFactor(self::TWO_FACTOR_MECHANISM_EMAIL, $otpValue);
}
/**
* Completes the previously started setup of two-factor authentification via a specified mechanism
*