This commit is contained in:
Jake Barnby
2025-03-18 22:25:37 +13:00
parent 13a50ee6e5
commit c453252c39
2 changed files with 10 additions and 6 deletions
+10 -5
View File
@@ -329,7 +329,8 @@ App::post('/v1/account')
$limit = $project->getAttribute('auths', [])['limit'] ?? 0;
if ($limit !== 0) {
$total = $useProjectDB(fn (Database $dbForProject) =>
$total = $useProjectDB(
fn (Database $dbForProject) =>
$dbForProject->count('users', max: APP_LIMIT_USERS)
);
@@ -342,7 +343,8 @@ App::post('/v1/account')
}
// Makes sure this email is not already used in another identity
$identityWithMatchingEmail = $useProjectDB(fn (Database $dbForProject) =>
$identityWithMatchingEmail = $useProjectDB(
fn (Database $dbForProject) =>
$dbForProject->findOne('identities', [
Query::equal('providerEmail', [$email]),
])
@@ -391,11 +393,13 @@ App::post('/v1/account')
'accessedAt' => DateTime::now(),
]);
$user->removeAttribute('$internalId');
$user = Authorization::skip(fn () => $useProjectDB(fn (Database $dbForProject) =>
$user = Authorization::skip(fn () => $useProjectDB(
fn (Database $dbForProject) =>
$dbForProject->createDocument('users', $user)
));
try {
$target = Authorization::skip(fn () => $useProjectDB(fn (Database $dbForProject) =>
$target = Authorization::skip(fn () => $useProjectDB(
fn (Database $dbForProject) =>
$dbForProject->createDocument('targets', new Document([
'$permissions' => [
Permission::read(Role::user($user->getId())),
@@ -418,7 +422,8 @@ App::post('/v1/account')
}
}
$useProjectDB(fn (Database $dbForProject) =>
$useProjectDB(
fn (Database $dbForProject) =>
$dbForProject->purgeCachedDocument('users', $user->getId())
);
} catch (Duplicate) {
-1
View File
@@ -36,7 +36,6 @@ use Utopia\Database\Validator\Authorization;
use Utopia\DSN\DSN;
use Utopia\Locale\Locale;
use Utopia\Logger\Log;
use Utopia\Pools\Connection;
use Utopia\Pools\Group;
use Utopia\Queue\Publisher;
use Utopia\Storage\Device;