Improve 409 rule error; update console

This commit is contained in:
Matej Baco
2023-03-10 13:36:31 +00:00
parent 4b0d6d9826
commit 2d25514dd8
4 changed files with 16 additions and 10 deletions
-7
View File
@@ -892,13 +892,6 @@ $collections = [
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_redirect'),
'type' => Database::INDEX_KEY,
'attributes' => ['redirect'],
'lengths' => [],
'orders' => [Database::ORDER_ASC],
],
[
'$id' => ID::custom('_key_status'),
'type' => Database::INDEX_KEY,
+1 -1
View File
@@ -546,7 +546,7 @@ return [
],
Exception::RULE_ALREADY_EXISTS => [
'name' => Exception::RULE_ALREADY_EXISTS,
'description' => 'A rule with the requested domain already exists.',
'description' => 'Domain already used.',
'code' => 409,
],
Exception::RULE_VERIFICATION_FAILED => [
+14 -1
View File
@@ -49,7 +49,20 @@ App::post('/v1/proxy/rules')
]);
if ($document && !$document->isEmpty()) {
throw new Exception(Exception::RULE_ALREADY_EXISTS);
if($document->getAttribute('projectId') === $project->getId()) {
$resourceType = $document->getAttribute('resourceType');
$resourceId = $document->getAttribute('resourceId');
$message = "Domain already assigned to '{$resourceType}' service";
if(!empty($resourceId)) {
$message .= " with ID '{$resourceId}'";
}
$message .= '.';
} else {
$message = "Domain already assigned to different project.";
}
throw new Exception(Exception::RULE_ALREADY_EXISTS, $message);
}
$target = new Domain(App::getEnv('_APP_DOMAIN_TARGET', ''));