【发布时间】:2011-09-01 08:13:06
【问题描述】:
class CommentsController extends AppController {
function beforeFilter() {
parent::beforeFilter();
$this->Auth->allowedActions = array('add','edit');
}
但是如果我这样做 http://mysite.com/comments/view/13 我得到了错误 =>
Error: The action view is not defined in controller CommentsController
Error: Create CommentsController::view() in file: app/controllers/comments_controller.php.
<?php
class CommentsController extends AppController {
var $name = 'Comments';
function view() {
}
}
?>
Notice: If you want to customize this error message, create app/views/errors/missing_action.ctp
对于http://mysite.com/comments/edit/13 =>
我得到了带有该评论的编辑页面。那不应该来。在编辑任何帖子之前应该提示我登录。
为什么不工作?
【问题讨论】:
-
嗯,你的控制器中有
view()方法吗? -
我没有在 cmets 控制器中查看方法。但是有 edit($id) 操作,所以我怎样才能停止执行这个 url mysite.com/comments/edit/13 ?
-
不允许的动作和不存在的动作是有区别的。对于后者,无论身份验证如何,您总是会收到 404 错误。
标签: php authentication cakephp cakephp-1.3