CakePHP:如何访问Auth->;允许操作数组?

CakePHP:如何访问Auth->;允许操作数组?,cakephp,authorization,Cakephp,Authorization,我一直在使用CakePHP2.6开发一个应用程序。我们有一个名为AuthUser的类,它建立在AuthComponent功能的基础上,允许我们根据角色检查数据库中节的权限 但是我注意到,我们的“IsAuthorized”函数忽略了$this->Auth->allow(),这意味着我们的检查会捕获不需要授权的操作,需要更新以正确检查 是否可以访问$this->Auth->allow()操作数组?如果可以,人们将如何访问它 下面我包含了AuthUser类中的“IsAuthorized”函数: pub

我一直在使用CakePHP2.6开发一个应用程序。我们有一个名为AuthUser的类,它建立在AuthComponent功能的基础上,允许我们根据角色检查数据库中节的权限

但是我注意到,我们的“IsAuthorized”函数忽略了
$this->Auth->allow()
,这意味着我们的检查会捕获不需要授权的操作,需要更新以正确检查

是否可以访问
$this->Auth->allow()
操作数组?如果可以,人们将如何访问它

下面我包含了AuthUser类中的“IsAuthorized”函数:

public function isAuthorised($controllerName = null) {
        //Admin has access to everything
        if (AuthUser::isAdmin() === true) {
            return true;
        }

        $roles = array();

        //Get the roles allowed for the section
        $results = AppController::runStoredProcedure('spGetCurrentSectionRolesForSectionBySectionName', array( $controllerName ));

        if (isset($results) && is_array($results)) {
            foreach ($results as $row) {
                if (isset($row['RoleName'])) {
                    array_push($roles, $row['RoleName']);
                }
            }
        }

        //Check if authenticated user has permission to current controller (is one of the allowed roles)
        $userRoles = AuthComponent::user('role');

        if (isset($userRoles) && is_array($userRoles)) {
            foreach ($userRoles as $key => $value) {
                if ($value == true) {5
                    if (in_array($key, $roles)) {
                        return true;
                    }
                }
            }
        }

        return false;
    }
请试试这个

pr($this->Auth->allowedActions);
这将列出在
$This->auth->allow()中定义的所有auth->allow()函数名。请尝试此操作

pr($this->Auth->allowedActions);

这将列出在
$This->auth->allow()中定义的所有auth->allow()函数名,谢谢!另外,是否有方法检查其他控制器允许的操作,例如呈现postlink按钮?没有,只有$this->Auth->allow();在运行时读取数组,因此我们无法访问其他控制器允许函数。这将给出所有父类或子类函数列表谢谢!另外,是否有方法检查其他控制器允许的操作,例如呈现postlink按钮?没有,只有$this->Auth->allow();在运行时读取数组,因此我们无法访问其他控制器允许函数。这将给出所有父类或子类函数列表