mirror of
https://github.com/appwrite/appwrite
synced 2026-05-24 09:28:40 +00:00
Fix double rule IDs
This commit is contained in:
parent
e3c4cdb040
commit
2f328bf4cf
1 changed files with 5 additions and 8 deletions
|
|
@ -98,16 +98,14 @@ class CreateSite extends Base
|
||||||
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $subdomain, string $buildRuntime, string $serveRuntime, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github)
|
public function action(string $siteId, string $name, string $framework, bool $enabled, int $timeout, string $installCommand, string $buildCommand, string $outputDirectory, string $subdomain, string $buildRuntime, string $serveRuntime, string $installationId, string $providerRepositoryId, string $providerBranch, bool $providerSilentMode, string $providerRootDirectory, string $templateRepository, string $templateOwner, string $templateRootDirectory, string $templateVersion, string $specification, Request $request, Response $response, Database $dbForProject, Document $project, Document $user, Event $queueForEvents, Build $queueForBuilds, Database $dbForConsole, GitHub $github)
|
||||||
{
|
{
|
||||||
$sitesDomain = System::getEnv('_APP_DOMAIN_SITES', '');
|
$sitesDomain = System::getEnv('_APP_DOMAIN_SITES', '');
|
||||||
$ruleId = '';
|
|
||||||
$routeSubdomain = '';
|
$routeSubdomain = '';
|
||||||
$domain = '';
|
$domain = '';
|
||||||
|
|
||||||
if (!empty($sitesDomain)) {
|
if (!empty($sitesDomain)) {
|
||||||
$routeSubdomain = $subdomain ?: ID::unique();
|
$routeSubdomain = $subdomain ?: ID::unique();
|
||||||
$domain = "{$routeSubdomain}.{$sitesDomain}";
|
$domain = "{$routeSubdomain}.{$sitesDomain}";
|
||||||
$ruleId = md5($domain);
|
|
||||||
|
|
||||||
$subdomain = Authorization::skip(fn () => $dbForConsole->getDocument('rules', $ruleId));
|
$subdomain = Authorization::skip(fn () => $dbForConsole->getDocument('rules', \md5($domain)));
|
||||||
|
|
||||||
if ($subdomain && !$subdomain->isEmpty()) {
|
if ($subdomain && !$subdomain->isEmpty()) {
|
||||||
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Subdomain already exists. Please choose a different subdomain.');
|
throw new Exception(Exception::GENERAL_ARGUMENT_INVALID, 'Subdomain already exists. Please choose a different subdomain.');
|
||||||
|
|
@ -230,15 +228,14 @@ class CreateSite extends Base
|
||||||
$projectId = $project->getId();
|
$projectId = $project->getId();
|
||||||
|
|
||||||
$sitesDomain = System::getEnv('_APP_DOMAIN_SITES', '');
|
$sitesDomain = System::getEnv('_APP_DOMAIN_SITES', '');
|
||||||
$domain = "{$deploymentId}-{$projectId}.{$sitesDomain}";
|
$previewDomain = "{$deploymentId}-{$projectId}.{$sitesDomain}";
|
||||||
$ruleId = md5($domain);
|
|
||||||
|
|
||||||
$rule = Authorization::skip(
|
$rule = Authorization::skip(
|
||||||
fn() => $dbForConsole->createDocument('rules', new Document([
|
fn() => $dbForConsole->createDocument('rules', new Document([
|
||||||
'$id' => $ruleId,
|
'$id' => \md5($previewDomain),
|
||||||
'projectId' => $project->getId(),
|
'projectId' => $project->getId(),
|
||||||
'projectInternalId' => $project->getInternalId(),
|
'projectInternalId' => $project->getInternalId(),
|
||||||
'domain' => $domain,
|
'domain' => $previewDomain,
|
||||||
'resourceType' => 'deployment',
|
'resourceType' => 'deployment',
|
||||||
'resourceId' => $deploymentId,
|
'resourceId' => $deploymentId,
|
||||||
'resourceInternalId' => $deployment->getInternalId(),
|
'resourceInternalId' => $deployment->getInternalId(),
|
||||||
|
|
@ -257,7 +254,7 @@ class CreateSite extends Base
|
||||||
if (!empty($sitesDomain)) {
|
if (!empty($sitesDomain)) {
|
||||||
$rule = Authorization::skip(
|
$rule = Authorization::skip(
|
||||||
fn () => $dbForConsole->createDocument('rules', new Document([
|
fn () => $dbForConsole->createDocument('rules', new Document([
|
||||||
'$id' => $ruleId,
|
'$id' => \md5($domain),
|
||||||
'projectId' => $project->getId(),
|
'projectId' => $project->getId(),
|
||||||
'projectInternalId' => $project->getInternalId(),
|
'projectInternalId' => $project->getInternalId(),
|
||||||
'domain' => $domain,
|
'domain' => $domain,
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue