diff --git a/application/core/APIv1_Controller.php b/application/core/APIv1_Controller.php
index 43790c080..97f8d43d8 100644
--- a/application/core/APIv1_Controller.php
+++ b/application/core/APIv1_Controller.php
@@ -29,7 +29,7 @@ class APIv1_Controller extends REST_Controller
*/
private function _isAllowed($requiredPermissions)
{
- if (!$this->permissionlib->checkPermissions($requiredPermissions, $this->router->method))
+ if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method))
{
$this->response(error('You are not allowed to access to this content'), REST_Controller::HTTP_UNAUTHORIZED);
}
diff --git a/application/core/FHC_Controller.php b/application/core/FHC_Controller.php
index fab8aea32..316e56425 100644
--- a/application/core/FHC_Controller.php
+++ b/application/core/FHC_Controller.php
@@ -28,7 +28,7 @@ class FHC_Controller extends CI_Controller
*/
private function _isAllowed($requiredPermissions)
{
- if (!$this->permissionlib->checkPermissions($requiredPermissions, $this->router->method))
+ if (!$this->permissionlib->isEntitled($requiredPermissions, $this->router->method))
{
header('HTTP/1.0 401 Unauthorized');
echo 'You are not allowed to access to this content';
diff --git a/application/libraries/PermissionLib.php b/application/libraries/PermissionLib.php
index c43f6dec0..4757b8643 100644
--- a/application/libraries/PermissionLib.php
+++ b/application/libraries/PermissionLib.php
@@ -67,34 +67,6 @@ class PermissionLib
}
}
- /**
- * Check if the user is entitled to get access to a source with the given access type
- *
- * @return bool true if a user has the right to access to the specified
- * resource with a specified permission type, false otherwise
- */
- public function isEntitled($sourceName, $permissionType)
- {
- $isEntitled = false;
-
- // If it's called from command line than it's trusted
- if (!is_cli())
- {
- // If the resource exists
- if (isset($this->acl[$sourceName]))
- {
- // Checks permission
- $isEntitled = $this->isBerechtigt($this->acl[$sourceName], $permissionType);
- }
- }
- else
- {
- $isEntitled = true;
- }
-
- return $isEntitled;
- }
-
/**
* Get a permission by a given source
*/
@@ -130,6 +102,7 @@ class PermissionLib
/**
* Checks if the caller is allowed to access to this content with the given permissions
+ * - if it's called from command line than it's trusted
* - checks if the parameter $requiredPermissions is set, is an array and contains at least one element
* - checks if the given $requiredPermissions parameter contains the called method of the controller
* - checks if the HTTP method used to call is GET or POST
@@ -145,11 +118,14 @@ class PermissionLib
* NOTE: the displayed error messages are used to warn the developer about any issues that could occur,
* they are not intended for the final user!
*/
- public function checkPermissions($requiredPermissions, $calledMethod)
+ public function isEntitled($requiredPermissions, $calledMethod)
{
$checkPermissions = false;
$requestMethod = $_SERVER['REQUEST_METHOD'];
+ // If it's called from command line than it's trusted
+ if (is_cli()) return true;
+
// Checks if the parameter $requiredPermissions is set, is an array and contains at least one element
if (isset($requiredPermissions) && is_array($requiredPermissions) && count($requiredPermissions) > 0)
{