mirror of
https://github.com/appwrite/appwrite.git
synced 2026-11-18 20:36:03 +00:00
Merge branch '1.7.x' into feat-SER-67-restrict-invalid-domains
This commit is contained in:
4 files changed
+53
-2
No files matched your search
@@ -2239,7 +2239,30 @@ App::post('/v1/account/tokens/email')
|
||||
]);
|
||||
|
||||
$user->removeAttribute('$sequence');
|
||||
Authorization::skip(fn () => $dbForProject->createDocument('users', $user));
|
||||
$user = Authorization::skip(fn () => $dbForProject->createDocument('users', $user));
|
||||
try {
|
||||
$target = Authorization::skip(fn () => $dbForProject->createDocument('targets', new Document([
|
||||
'$permissions' => [
|
||||
Permission::read(Role::user($user->getId())),
|
||||
Permission::update(Role::user($user->getId())),
|
||||
Permission::delete(Role::user($user->getId())),
|
||||
],
|
||||
'userId' => $user->getId(),
|
||||
'userInternalId' => $user->getSequence(),
|
||||
'providerType' => MESSAGE_TYPE_EMAIL,
|
||||
'identifier' => $email,
|
||||
])));
|
||||
$user->setAttribute('targets', [...$user->getAttribute('targets', []), $target]);
|
||||
} catch (Duplicate) {
|
||||
$existingTarget = $dbForProject->findOne('targets', [
|
||||
Query::equal('identifier', [$email]),
|
||||
]);
|
||||
if (!$existingTarget->isEmpty()) {
|
||||
$user->setAttribute('targets', $existingTarget, Document::SET_TYPE_APPEND);
|
||||
}
|
||||
}
|
||||
|
||||
$dbForProject->purgeCachedDocument('users', $user->getId());
|
||||
}
|
||||
|
||||
$tokenSecret = Auth::codeGenerator(6);
|
||||
|
||||
@@ -3453,6 +3453,7 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
|
||||
} else {
|
||||
$relation->removeAttribute('$collectionId');
|
||||
$relation->removeAttribute('$databaseId');
|
||||
$relation->removeAttribute('$sequence');
|
||||
$relation->setAttribute('$collection', $relatedCollection->getId());
|
||||
$type = Database::PERMISSION_UPDATE;
|
||||
}
|
||||
@@ -3485,6 +3486,9 @@ App::post('/v1/databases/:databaseId/collections/:collectionId/documents')
|
||||
}
|
||||
}
|
||||
|
||||
// Remove sequence if set
|
||||
unset($document['$sequence']);
|
||||
|
||||
// Assign a unique ID if needed, otherwise use the provided ID.
|
||||
$document['$id'] = $sourceId === 'unique()' ? ID::unique() : $sourceId;
|
||||
$document = new Document($document);
|
||||
@@ -4074,6 +4078,9 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||
$permissions = $document->getPermissions() ?? [];
|
||||
}
|
||||
|
||||
// Remove sequence if set
|
||||
unset($data['$sequence']);
|
||||
|
||||
$data['$id'] = $documentId;
|
||||
$data['$permissions'] = $permissions;
|
||||
$newDocument = new Document($data);
|
||||
@@ -4126,6 +4133,7 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents/:docum
|
||||
));
|
||||
$relation->removeAttribute('$collectionId');
|
||||
$relation->removeAttribute('$databaseId');
|
||||
$relation->removeAttribute('$sequence');
|
||||
// Attribute $collection is required for Utopia.
|
||||
$relation->setAttribute(
|
||||
'$collection',
|
||||
@@ -4708,6 +4716,9 @@ App::patch('/v1/databases/:databaseId/collections/:collectionId/documents')
|
||||
}
|
||||
}
|
||||
|
||||
// Remove sequence if set
|
||||
unset($data['$sequence']);
|
||||
|
||||
$documents = [];
|
||||
|
||||
try {
|
||||
|
||||
@@ -122,6 +122,19 @@ class Maintenance extends Action
|
||||
Console::info("[{$time}] Found " . \count($certificates) . " certificates for renewal, scheduling jobs.");
|
||||
|
||||
foreach ($certificates as $certificate) {
|
||||
$domain = $certificate->getAttribute('domain');
|
||||
if (System::getEnv('_APP_RULES_FORMAT') === 'md5') {
|
||||
$rule = $dbForPlatform->getDocument('rules', md5($domain));
|
||||
} else {
|
||||
$rule = $dbForPlatform->findOne('rules', [
|
||||
Query::equal('domain', [$domain]),
|
||||
]);
|
||||
}
|
||||
|
||||
if ($rule->isEmpty() || $rule->getAttribute('region') !== System::getEnv('_APP_REGION', 'default')) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$queueForCertificate
|
||||
->setDomain(new Document([
|
||||
'domain' => $certificate->getAttribute('domain')
|
||||
|
||||
@@ -39,6 +39,8 @@ trait AccountBase
|
||||
$this->assertEquals($response['body']['labels'], []);
|
||||
$this->assertArrayHasKey('accessedAt', $response['body']);
|
||||
$this->assertNotEmpty($response['body']['accessedAt']);
|
||||
$this->assertArrayHasKey('targets', $response['body']);
|
||||
$this->assertEquals($email, $response['body']['targets'][0]['identifier']);
|
||||
|
||||
/**
|
||||
* Test for FAILURE
|
||||
@@ -159,7 +161,7 @@ trait AccountBase
|
||||
'email' => 'otpuser@appwrite.io'
|
||||
]);
|
||||
|
||||
$this->assertEquals(201, $response['headers']['status-code'], );
|
||||
$this->assertEquals(201, $response['headers']['status-code']);
|
||||
$this->assertNotEmpty($response['body']['$id']);
|
||||
$this->assertNotEmpty($response['body']['$createdAt']);
|
||||
$this->assertNotEmpty($response['body']['userId']);
|
||||
@@ -209,6 +211,8 @@ trait AccountBase
|
||||
$this->assertEquals($userId, $response['body']['$id']);
|
||||
$this->assertEquals($userId, $response['body']['$id']);
|
||||
$this->assertTrue($response['body']['emailVerification']);
|
||||
$this->assertArrayHasKey('targets', $response['body']);
|
||||
$this->assertEquals('otpuser@appwrite.io', $response['body']['targets'][0]['identifier']);
|
||||
|
||||
$response = $this->client->call(Client::METHOD_POST, '/account/sessions/token', array_merge([
|
||||
'origin' => 'http://localhost',
|
||||
|
||||
Reference in new issue
Block a user