mirror of
https://github.com/grocy/grocy.git
synced 2025-08-16 02:34:44 +00:00
Applied formatting rules for by #986 changed files
This commit is contained in:
@@ -13,8 +13,10 @@ class GenericEntityApiController extends BaseApiController
|
|||||||
|
|
||||||
if ($this->IsValidEntity($args['entity']))
|
if ($this->IsValidEntity($args['entity']))
|
||||||
{
|
{
|
||||||
if($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
if ($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
||||||
|
{
|
||||||
User::checkPermission($request, User::PERMISSION_ADMIN);
|
User::checkPermission($request, User::PERMISSION_ADMIN);
|
||||||
|
}
|
||||||
|
|
||||||
$requestBody = $request->getParsedBody();
|
$requestBody = $request->getParsedBody();
|
||||||
|
|
||||||
@@ -50,8 +52,10 @@ class GenericEntityApiController extends BaseApiController
|
|||||||
|
|
||||||
if ($this->IsValidEntity($args['entity']))
|
if ($this->IsValidEntity($args['entity']))
|
||||||
{
|
{
|
||||||
if($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
if ($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
||||||
|
{
|
||||||
User::checkPermission($request, User::PERMISSION_ADMIN);
|
User::checkPermission($request, User::PERMISSION_ADMIN);
|
||||||
|
}
|
||||||
$row = $this->getDatabase()->{$args['entity']}
|
$row = $this->getDatabase()->{$args['entity']}
|
||||||
($args['objectId']);
|
($args['objectId']);
|
||||||
$row->delete();
|
$row->delete();
|
||||||
@@ -70,8 +74,10 @@ class GenericEntityApiController extends BaseApiController
|
|||||||
|
|
||||||
if ($this->IsValidEntity($args['entity']))
|
if ($this->IsValidEntity($args['entity']))
|
||||||
{
|
{
|
||||||
if($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
if ($this->IsEntityWithEditRequiresAdmin($args['entity']))
|
||||||
|
{
|
||||||
User::checkPermission($request, User::PERMISSION_ADMIN);
|
User::checkPermission($request, User::PERMISSION_ADMIN);
|
||||||
|
}
|
||||||
$requestBody = $request->getParsedBody();
|
$requestBody = $request->getParsedBody();
|
||||||
|
|
||||||
try
|
try
|
||||||
@@ -218,6 +224,7 @@ class GenericEntityApiController extends BaseApiController
|
|||||||
{
|
{
|
||||||
parent::__construct($container);
|
parent::__construct($container);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function IsEntityWithEditRequiresAdmin($entity)
|
private function IsEntityWithEditRequiresAdmin($entity)
|
||||||
{
|
{
|
||||||
return !in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->EntityEditRequiresAdmin->enum);
|
return !in_array($entity, $this->getOpenApiSpec()->components->internalSchemas->EntityEditRequiresAdmin->enum);
|
||||||
|
@@ -9,10 +9,12 @@ class OpenApiController extends BaseApiController
|
|||||||
public function ApiKeysList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
public function ApiKeysList(\Psr\Http\Message\ServerRequestInterface $request, \Psr\Http\Message\ResponseInterface $response, array $args)
|
||||||
{
|
{
|
||||||
$apiKeys = $this->getDatabase()->api_keys();
|
$apiKeys = $this->getDatabase()->api_keys();
|
||||||
if(!User::hasPermissions(User::PERMISSION_ADMIN))
|
if (!User::hasPermissions(User::PERMISSION_ADMIN))
|
||||||
|
{
|
||||||
$apiKeys = $apiKeys->where('user_id', GROCY_USER_ID);
|
$apiKeys = $apiKeys->where('user_id', GROCY_USER_ID);
|
||||||
|
}
|
||||||
return $this->renderPage($response, 'manageapikeys', [
|
return $this->renderPage($response, 'manageapikeys', [
|
||||||
'apiKeys' =>$apiKeys,
|
'apiKeys' => $apiKeys,
|
||||||
'users' => $this->getDatabase()->users()
|
'users' => $this->getDatabase()->users()
|
||||||
]);
|
]);
|
||||||
}
|
}
|
||||||
|
@@ -172,7 +172,8 @@ function animateCSS(selector, animationName, callback, speed = "faster")
|
|||||||
|
|
||||||
nodes.on('animationend', handleAnimationEnd);
|
nodes.on('animationend', handleAnimationEnd);
|
||||||
}
|
}
|
||||||
function RandomString() {
|
function RandomString()
|
||||||
|
{
|
||||||
return Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
|
return Math.random().toString(36).substring(2, 100) + Math.random().toString(36).substring(2, 100);
|
||||||
}
|
}
|
||||||
function getQRCodeForContent(url)
|
function getQRCodeForContent(url)
|
||||||
@@ -185,7 +186,7 @@ function getQRCodeForContent(url)
|
|||||||
function getQRCodeForAPIKey(apikey_type, apikey_key)
|
function getQRCodeForAPIKey(apikey_type, apikey_key)
|
||||||
{
|
{
|
||||||
var content = U('/api') + '|' + apikey_key;
|
var content = U('/api') + '|' + apikey_key;
|
||||||
if(apikey_type === 'special-purpose-calendar-ical')
|
if (apikey_type === 'special-purpose-calendar-ical')
|
||||||
{
|
{
|
||||||
content = U('/api/calendar/ical?secret=' + apikey_key);
|
content = U('/api/calendar/ical?secret=' + apikey_key);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user