我正在尝试根据用户的类型(即学生、管理员、员工)授权用户,这是我编写的代码AppController.php
。
public function isAuthorized($user = null) {
// Any registered user can access public functions
if (empty($this->request->params['admin']) && empty($this->request->params["staff"])) {
return true;
}
if(isset($this->request->params["staff"])){
return (bool)($user["type"]==="staff" || $user["type"]==="admin");
}
// Only admins can access admin functions
if (isset($this->request->params['admin'])) {
return (bool)($user['type'] === 'admin');
}
// Default deny
return false;
}
以“学生”身份登录后,我在地址栏中键入localhost/kit-web/admin
以确保“学生”没有访问管理页面的权限。但奇怪的是,网页被重定向到localhost/kit-web/kit-web
. 这导致了missing Kit-webController.php
错误。如果任何用户有权访问某个页面,那么一切正常。
我猜一个可能的原因是我使用composer安装了CakePHP,所以目录配置与解压缩的不同。但是,我已经按照 cakephp 教程
配置了ROOT
、 、 APP_DIR 的位置。
有谁知道出了什么问题?CAKE_CORE_INCLUDE_PATH