Normalize algorithm being used

This commit is contained in:
Bradley Schofield
2024-09-18 16:30:02 +09:00
parent be3e3790c9
commit e88cfed03a
5 changed files with 11 additions and 11 deletions
+5 -5
View File
@@ -395,7 +395,7 @@ Http::post('/v1/account')
$existingTarget = $dbForProject->findOne('targets', [
Query::equal('identifier', [$email]),
]);
if ($existingTarget !== false && !$existingTarget->isEmpty()) {
if (!empty($existingTarget) && !$existingTarget->isEmpty()) {
$user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND);
}
}
@@ -840,7 +840,7 @@ Http::post('/v1/account/sessions/email')
Query::equal('email', [$email]),
]);
if ($profile === false || $profile->isEmpty() || empty($profile->getAttribute('passwordUpdate')) || !Auth::passwordVerify($password, $profile->getAttribute('password'), $profile->getAttribute('hash'), $profile->getAttribute('hashOptions'))) {
if (empty($profile) || $profile->isEmpty() || empty($profile->getAttribute('passwordUpdate')) || !Auth::passwordVerify($password, $profile->getAttribute('password'), $profile->getAttribute('hash'), $profile->getAttribute('hashOptions'))) {
throw new Exception(Exception::USER_INVALID_CREDENTIALS);
}
@@ -1386,7 +1386,7 @@ Http::get('/v1/account/sessions/oauth2/:provider/redirect')
Query::equal('providerEmail', [$email]),
Query::notEqual('userInternalId', $user->getInternalId()),
]);
if ($identityWithMatchingEmail !== false && !$identityWithMatchingEmail->isEmpty()) {
if (!empty($identityWithMatchingEmail) && !$identityWithMatchingEmail->isEmpty()) {
throw new Exception(Exception::USER_ALREADY_EXISTS);
}
@@ -2406,7 +2406,7 @@ Http::post('/v1/account/tokens/phone')
$existingTarget = $dbForProject->findOne('targets', [
Query::equal('identifier', [$phone]),
]);
$user->setAttribute('targets', [...$user->getAttribute('targets', []), $existingTarget->isEmpty() ? false : $existingTarget]);
$user->setAttribute('targets', [...$user->getAttribute('targets', []), (empty($existingTarget) || $existingTarget->isEmpty()) ? false : $existingTarget]);
}
$dbForProject->purgeCachedDocument('users', $user->getId());
}
@@ -3026,7 +3026,7 @@ Http::post('/v1/account/recovery')
Query::equal('email', [$email]),
]);
if ($profile === false || $profile->isEmpty()) {
if (empty($profile) || $profile->isEmpty()) {
throw new Exception(Exception::USER_NOT_FOUND);
}
+1 -1
View File
@@ -462,7 +462,7 @@ Http::post('/v1/teams/:teamId/memberships')
}
}
if (empty($invitee)) { // Create new user if no user with same email found
if (empty($invitee) || $invitee->isEmpty()) { // Create new user if no user with same email found
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
if (!$isPrivilegedUser && !$isAppUser && $limit !== 0 && $project->getId() !== 'console') { // check users limit, console invites are allways allowed.
+2 -2
View File
@@ -140,7 +140,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e
$existingTarget = $dbForProject->findOne('targets', [
Query::equal('identifier', [$email]),
]);
if ($existingTarget !== false && !$existingTarget->isEmpty()) {
if (!empty($existingTarget) && !$existingTarget->isEmpty()) {
$user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND);
}
}
@@ -164,7 +164,7 @@ function createUser(string $hash, mixed $hashOptions, string $userId, ?string $e
$existingTarget = $dbForProject->findOne('targets', [
Query::equal('identifier', [$phone]),
]);
if ($existingTarget !== false && !$existingTarget->isEmpty()) {
if (!empty($existingTarget) && !$existingTarget->isEmpty()) {
$user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND);
}
}
+2 -2
View File
@@ -520,7 +520,7 @@ Http::init()
$mainDomain = $envDomain;
} else {
$domainDocument = $dbForConsole->findOne('rules', [Query::orderAsc('$id')]);
$mainDomain = ($domainDocument !== false && !$domainDocument->isEmpty()) ? $domainDocument->getAttribute('domain') : $domain->get();
$mainDomain = (!empty($domainDocument) && !$domainDocument->isEmpty()) ? $domainDocument->getAttribute('domain') : $domain->get();
}
if ($mainDomain !== $domain->get()) {
@@ -530,7 +530,7 @@ Http::init()
Query::equal('domain', [$domain->get()])
]);
if ($domainDocument === false || $domainDocument->isEmpty()) {
if (empty($domainDocument) || $domainDocument->isEmpty()) {
$domainDocument = new Document([
'domain' => $domain->get(),
'resourceType' => 'api',
@@ -126,7 +126,7 @@ class Certificates extends Action
$certificate = $dbForConsole->findOne('certificates', [Query::equal('domain', [$domain->get()])]);
// If we don't have certificate for domain yet, let's create new document. At the end we save it
if (!$certificate || $certificate->isEmpty()) {
if (empty($certificate) || $certificate->isEmpty()) {
$certificate = new Document();
$certificate->setAttribute('domain', $domain->get());
}