【问题标题】:CakePHP authentication problem, allowedActions is not workingCakePHP 身份验证问题,allowedActions 不起作用
【发布时间】: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


【解决方案1】:

I got the edit page with that comment. That should not come. I should be prompted to login before editing any post.

删除$this-&gt;Auth-&gt;allowedActions = array('add','edit');这一行

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-08-15
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2014-05-22
    相关资源
    最近更新 更多