diff --git a/app/config/collections.php b/app/config/collections.php index 40c64fc801..100119e300 100644 --- a/app/config/collections.php +++ b/app/config/collections.php @@ -1205,6 +1205,7 @@ $collections = [ ] ], ], +]; $commonCollections = [ 'users' => [ diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index e664a6b764..18c2d0aaa4 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -3292,18 +3292,18 @@ App::post('/v1/account/mfa/:provider') $backups = Provider::generateBackupCodes(); - switch ($provider) { - case 'totp': - if ($user->getAttribute('totp') && $user->getAttribute('totpVerification')) { - throw new Exception(Exception::GENERAL_UNKNOWN, 'TOTP already exists.'); - } - $user - ->setAttribute('totp', true) - ->setAttribute('totpVerification', false) - ->setAttribute('totpBackup', $backups) - ->setAttribute('totpSecret', $otp->getSecret()); - break; - } + switch ($provider) { + case 'totp': + if ($user->getAttribute('totp') && $user->getAttribute('totpVerification')) { + throw new Exception(Exception::GENERAL_UNKNOWN, 'TOTP already exists.'); + } + $user + ->setAttribute('totp', true) + ->setAttribute('totpVerification', false) + ->setAttribute('totpBackup', $backups) + ->setAttribute('totpSecret', $otp->getSecret()); + break; + } $model = new Document(); $model @@ -3351,20 +3351,20 @@ App::put('/v1/account/mfa/:provider') default => false }; - if (!$success) { - throw new Exception(Exception::USER_INVALID_TOKEN); - } + if (!$success) { + throw new Exception(Exception::USER_INVALID_TOKEN); + } - switch ($provider) { - case 'totp': - if (!$user->getAttribute('totp')) { - throw new Exception(Exception::GENERAL_UNKNOWN, 'TOTP not added.'); - } elseif ($user->getAttribute('totpVerification')) { - throw new Exception(Exception::GENERAL_UNKNOWN, 'TOTP already verified.'); - } - $user->setAttribute('totpVerification', true); - break; - } + switch ($provider) { + case 'totp': + if (!$user->getAttribute('totp')) { + throw new Exception(Exception::GENERAL_UNKNOWN, 'TOTP not added.'); + } elseif ($user->getAttribute('totpVerification')) { + throw new Exception(Exception::GENERAL_UNKNOWN, 'TOTP already verified.'); + } + $user->setAttribute('totpVerification', true); + break; + } $user = $dbForProject->withRequestTimestamp($requestTimestamp, fn () => $dbForProject->updateDocument('users', $user->getId(), $user)); @@ -3508,9 +3508,9 @@ App::put('/v1/account/mfa/challenge') default => false }; - if (!$success) { - throw new Exception(Exception::USER_INVALID_TOKEN); - } + if (!$success) { + throw new Exception(Exception::USER_INVALID_TOKEN); + } $dbForProject->deleteDocument('challenges', $challengeId); $dbForProject->deleteCachedDocument('users', $user->getId());