mirror of
https://github.com/grocy/grocy.git
synced 2025-08-15 02:04:38 +00:00
Fixed API key deletion was not possible (fixes #1203)
This commit is contained in:
@@ -50,7 +50,7 @@ class GenericEntityApiController extends BaseApiController
|
|||||||
{
|
{
|
||||||
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
|
User::checkPermission($request, User::PERMISSION_MASTER_DATA_EDIT);
|
||||||
|
|
||||||
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoEdit($args['entity']))
|
if ($this->IsValidExposedEntity($args['entity']) && !$this->IsEntityWithNoDelete($args['entity']))
|
||||||
{
|
{
|
||||||
if ($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
if ($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
||||||
{
|
{
|
||||||
@@ -219,6 +219,11 @@ class GenericEntityApiController extends BaseApiController
|
|||||||
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoEdit->enum);
|
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoEdit->enum);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private function IsEntityWithNoDelete($entity)
|
||||||
|
{
|
||||||
|
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntityNoDelete->enum);
|
||||||
|
}
|
||||||
|
|
||||||
private function IsValidExposedEntity($entity)
|
private function IsValidExposedEntity($entity)
|
||||||
{
|
{
|
||||||
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntity->enum);
|
return in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->ExposedEntity->enum);
|
||||||
|
@@ -45,6 +45,15 @@ class OpenApiController extends BaseApiController
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotDeletable = clone $spec->components->internalSchemas->StringEnumTemplate;
|
||||||
|
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
|
||||||
|
{
|
||||||
|
if (!in_array($value, $spec->components->internalSchemas->ExposedEntityNoDelete->enum))
|
||||||
|
{
|
||||||
|
array_push($spec->components->internalSchemas->ExposedEntity_NotIncludingNotDeletable->enum, $value);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotListable = clone $spec->components->internalSchemas->StringEnumTemplate;
|
$spec->components->internalSchemas->ExposedEntity_NotIncludingNotListable = clone $spec->components->internalSchemas->StringEnumTemplate;
|
||||||
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
|
foreach ($spec->components->internalSchemas->ExposedEntity->enum as $value)
|
||||||
{
|
{
|
||||||
|
@@ -528,7 +528,7 @@
|
|||||||
"required": true,
|
"required": true,
|
||||||
"description": "A valid entity name",
|
"description": "A valid entity name",
|
||||||
"schema": {
|
"schema": {
|
||||||
"$ref": "#/components/internalSchemas/ExposedEntity_NotIncludingNotEditable"
|
"$ref": "#/components/internalSchemas/ExposedEntity_NotIncludingNotDeletable"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
@@ -3938,7 +3938,8 @@
|
|||||||
"meal_plan",
|
"meal_plan",
|
||||||
"stock_log",
|
"stock_log",
|
||||||
"stock",
|
"stock",
|
||||||
"stock_current_locations"
|
"stock_current_locations",
|
||||||
|
"api_keys"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
"ExposedEntityNoListing": {
|
"ExposedEntityNoListing": {
|
||||||
@@ -3956,6 +3957,14 @@
|
|||||||
"stock_current_locations"
|
"stock_current_locations"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
"ExposedEntityNoDelete": {
|
||||||
|
"type": "string",
|
||||||
|
"enum": [
|
||||||
|
"stock_log",
|
||||||
|
"stock",
|
||||||
|
"stock_current_locations"
|
||||||
|
]
|
||||||
|
},
|
||||||
"ExposedEntityEditRequiresAdmin": {
|
"ExposedEntityEditRequiresAdmin": {
|
||||||
"type": "string",
|
"type": "string",
|
||||||
"enum": [
|
"enum": [
|
||||||
|
Reference in New Issue
Block a user