【发布时间】:2012-07-21 17:58:07
【问题描述】:
我在我的控制器的索引操作上设置了视图缓存,使用
class DiaryController extends AppController {
...
var $cacheAction = array('index' => "+56 hours");
function index($week = null) {
...
}
}
在app/config/core.php 中有以下选项:
Configure::write('Cache.check', true);
...
Cache::config('default', array('engine' => 'File'));
日记控制器(以及站点的其余部分!)上的索引操作应该只能由经过身份验证的用户访问,使用 AuthComponent 和
class AppController extends Controller {
...
var $components = array('Auth', 'Security', 'Session','Cookie','RequestHandler');
function beforeFilter() {
$this->Auth->userModel = 'Admin';
...
}
...
}
我想将站点的根目录映射到我的登录表单,使用
Router::connect('/', array('controller' => 'admin', 'action' => 'login'));
在app/config/routes.php。一切似乎都正常,直到我注销然后尝试在浏览器中访问mytestsite.com/diary/index。即使我没有登录,我仍然可以访问这些页面。我相信这是缓存的问题,因为我只能访问我在app/tmp/cache/views 中有文件的网址。将索引操作的$week 参数更改为我没有缓存文件的值会导致You are not authorized to access that location. 消息。
奇怪的是,如果我将站点的根目录映射到DiaryController 的索引操作,用
Router::connect('/', array('controller' => 'diary', 'action' => 'index'));
(再次在app/config/routes.php)我没有这个问题。当我没有登录时,我无法访问缓存的日记索引视图。
以前有人遇到过这个问题吗?你能建议我可能错过的东西吗?或者您知道这是否是核心文件中的错误?我正在使用 CakePHP 1.3.15。
【问题讨论】:
标签: cakephp authentication caching routes cakephp-1.3