mirror of
https://github.com/grocy/grocy.git
synced 2025-08-17 19:16:37 +00:00
Apikeys (#986)
* Add QR-Code for API-Url/Key * Show only API-Keys for current user * Allow only admin users to create custom API-Keys * Use a managed package of qrcode-generator instead of a copy of the JS file * Reuse existing localization string (API key) * Center QR-Code in popups Co-authored-by: Bernd Bestel <bernd@berrnd.de>
This commit is contained in:
committed by
GitHub
parent
40f379b761
commit
85a95f1973
@@ -13,6 +13,9 @@ class GenericEntityApiController extends BaseApiController
|
||||
|
||||
if ($this->IsValidEntity($args['entity']))
|
||||
{
|
||||
if($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
||||
User::checkPermission($request, User::PERMISSION_ADMIN);
|
||||
|
||||
$requestBody = $request->getParsedBody();
|
||||
|
||||
try
|
||||
@@ -47,6 +50,8 @@ class GenericEntityApiController extends BaseApiController
|
||||
|
||||
if ($this->IsValidEntity($args['entity']))
|
||||
{
|
||||
if($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
||||
User::checkPermission($request, User::PERMISSION_ADMIN);
|
||||
$row = $this->getDatabase()->{$args['entity']}
|
||||
($args['objectId']);
|
||||
$row->delete();
|
||||
@@ -65,6 +70,8 @@ class GenericEntityApiController extends BaseApiController
|
||||
|
||||
if ($this->IsValidEntity($args['entity']))
|
||||
{
|
||||
if($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
||||
User::checkPermission($request, User::PERMISSION_ADMIN);
|
||||
$requestBody = $request->getParsedBody();
|
||||
|
||||
try
|
||||
@@ -211,6 +218,10 @@ class GenericEntityApiController extends BaseApiController
|
||||
{
|
||||
parent::__construct($container);
|
||||
}
|
||||
private function IsEntityWithEditRequiresAdmin($entity)
|
||||
{
|
||||
return !in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->EntityEditRequiresAdmin->enum);
|
||||
}
|
||||
|
||||
private function IsEntityWithPreventedListing($entity)
|
||||
{
|
||||
|
Reference in New Issue
Block a user