0

我开始浏览 cakephp 教程,我完全按照教程中的说明复制源代码。

我已经完成了博客教程,一切似乎都很好,现在我进入了“简单的身份验证和授权应用程序”(http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/ auth.html ) 教程,但遇到了这个问题。

  1. 添加页面加载正常:

    “.../app/webroot/index.php/Users/add”

  2. 点击提交后,它会将我重定向到此 url(带有附加的“用户”字符串)并显示错误消息。

    “.../app/webroot/index.php/Users/Users/add”

    Missing Method in UsersController
    
    Error: The action Users is not defined in controller UsersController
    
    Error: Create UsersController::Users() in file: app/Controller/UsersController.php.
    
    class UsersController extends AppController {
    
    
    public function Users() {
    
    }
    
    }
    

让我知道我应该从哪里开始检查,谢谢。


应用控制器

    class AppController extends Controller {
        public $components = array(
            'Session',
            'Auth' => array(
                'loginRedirect' => array('controller' => 'posts', 'action' => 'index'),
                'logoutRedirect' => array('controller' => 'pages', 'action' => 'display', 'home'),
                'authorize' => array('Controller') // Added this line
            )
        );

        public function beforeFilter() {
            $this->Auth->allow('index', 'view');
       }

        public function isAuthorized($user) {
        // Admin can access every action
        if (isset($user['role']) && $user['role'] === 'admin') {
            return true;
        }

        // Default deny
        return false;
      }
    }
4

1 回答 1

1

因为我仍然无法发表评论,所以我会在这里告诉你,如果我知道的话,我会编辑这个答案。

给我看看你的AuthComponent配置AppController.php

编辑:

答案在下面的评论中。:)

于 2013-03-18T16:29:31.787 回答