diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index ea0141dc8..360babbb1 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -3521,12 +3521,16 @@ App::get('/v1/account/mfa/factors') ->inject('user') ->action(function (Response $response, Document $user) { + $mfaRecoveryCodes = $user->getAttribute('mfaRecoveryCodes', []); + $recoveryCodeEnabled = \is_array($mfaRecoveryCodes) && \count($mfaRecoveryCodes) > 0; + $totp = TOTP::getAuthenticatorFromUser($user); $factors = new Document([ Type::TOTP => $totp !== null && $totp->getAttribute('verified', false), Type::EMAIL => $user->getAttribute('email', false) && $user->getAttribute('emailVerification', false), - Type::PHONE => $user->getAttribute('phone', false) && $user->getAttribute('phoneVerification', false) + Type::PHONE => $user->getAttribute('phone', false) && $user->getAttribute('phoneVerification', false), + Type::RECOVERY_CODE => $recoveryCodeEnabled ]); $response->dynamic($factors, Response::MODEL_MFA_FACTORS); diff --git a/src/Appwrite/Utopia/Response/Model/MFAFactors.php b/src/Appwrite/Utopia/Response/Model/MFAFactors.php index 4f20000d1..47938ac07 100644 --- a/src/Appwrite/Utopia/Response/Model/MFAFactors.php +++ b/src/Appwrite/Utopia/Response/Model/MFAFactors.php @@ -13,19 +13,25 @@ class MFAFactors extends Model $this ->addRule(Type::TOTP, [ 'type' => self::TYPE_BOOLEAN, - 'description' => 'TOTP', + 'description' => 'Can TOTP be used for MFA challenge for this account.', 'default' => false, 'example' => true ]) ->addRule(Type::PHONE, [ 'type' => self::TYPE_BOOLEAN, - 'description' => 'Phone', + 'description' => 'Can phone (SMS) be used for MFA challenge for this account.', 'default' => false, 'example' => true ]) ->addRule(Type::EMAIL, [ 'type' => self::TYPE_BOOLEAN, - 'description' => 'Email', + 'description' => 'Can email be used for MFA challenge for this account.', + 'default' => false, + 'example' => true + ]) + ->addRule(Type::RECOVERY_CODE, [ + 'type' => self::TYPE_BOOLEAN, + 'description' => 'Can recovery code be used for MFA challenge for this account.', 'default' => false, 'example' => true ])