diff --git a/app/controllers/api/account.php b/app/controllers/api/account.php index 8c173844fe..8a6f951645 100644 --- a/app/controllers/api/account.php +++ b/app/controllers/api/account.php @@ -156,7 +156,7 @@ App::post('/v1/account/sessions') $email = \strtolower($email); $protocol = $request->getProtocol(); - $profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address + $profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address if (!$profile || !Auth::passwordVerify($password, $profile->getAttribute('password'))) { $audits @@ -442,16 +442,16 @@ App::get('/v1/account/sessions/oauth2/:provider/redirect') } } - $user = ($user->isEmpty()) ? $dbForInternal->findFirst('sessions', [ // Get user by provider id + $user = ($user->isEmpty()) ? $dbForInternal->findOne('sessions', [ // Get user by provider id new Query('provider', QUERY::TYPE_EQUAL, [$provider]), new Query('providerUid', QUERY::TYPE_EQUAL, [$oauth2ID]), - ], 1) : $user; + ]) : $user; if ($user === false || $user->isEmpty()) { // No user logged in or with OAuth2 provider ID, create new one or connect with account with same email $name = $oauth2->getUserName($accessToken); $email = $oauth2->getUserEmail($accessToken); - $user = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address + $user = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address if ($user === false || $user->isEmpty()) { // Last option -> create the user, generate random password $limit = $project->getAttribute('usersAuthLimit', 0); @@ -1074,7 +1074,7 @@ App::patch('/v1/account/email') } $email = \strtolower($email); - $profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [\strtolower($email)])], 1); // Get user by email address + $profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [\strtolower($email)])]); // Get user by email address if ($profile) { throw new Exception('User already registered', 400); @@ -1379,7 +1379,7 @@ App::post('/v1/account/recovery') $isAppUser = Auth::isAppUser(Authorization::$roles); $email = \strtolower($email); - $profile = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address + $profile = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address if (!$profile) { throw new Exception('User not found', 404); diff --git a/app/controllers/api/teams.php b/app/controllers/api/teams.php index b143be9b5c..921ef4163c 100644 --- a/app/controllers/api/teams.php +++ b/app/controllers/api/teams.php @@ -273,7 +273,7 @@ App::post('/v1/teams/:teamId/memberships') throw new Exception('Team not found', 404); } - $invitee = $dbForInternal->findFirst('users', [new Query('email', Query::TYPE_EQUAL, [$email])], 1); // Get user by email address + $invitee = $dbForInternal->findOne('users', [new Query('email', Query::TYPE_EQUAL, [$email])]); // Get user by email address if (empty($invitee)) { // Create new user if no user with same email found diff --git a/app/controllers/general.php b/app/controllers/general.php index af2147e4db..91b96edb83 100644 --- a/app/controllers/general.php +++ b/app/controllers/general.php @@ -44,9 +44,9 @@ App::init(function ($utopia, $request, $response, $console, $project, $dbForCons } else { Authorization::disable(); - $certificate = $dbForConsole->findFirst('certificates', [ + $certificate = $dbForConsole->findOne('certificates', [ new Query('domain', QUERY::TYPE_EQUAL, [$domain->get()]) - ], /*limit*/ 1); + ]); if (empty($certificate)) { $certificate = new Document([ diff --git a/app/workers/certificates.php b/app/workers/certificates.php index 1720d6adb9..96148b9e71 100644 --- a/app/workers/certificates.php +++ b/app/workers/certificates.php @@ -78,9 +78,9 @@ class CertificatesV1 extends Worker } } - $certificate = $dbForConsole->findFirst('certificates', [ + $certificate = $dbForConsole->findOne('certificates', [ new Query('domain', QUERY::TYPE_EQUAL, [$domain->get()]) - ], /*limit*/ 1); + ]); // $condition = ($certificate // && $certificate instanceof Document