Cakephp简单验证教程页面未重定向到当前页面

时间:2013-03-18 15:54:34

标签: cakephp

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

我已经完成了Blog教程,一切看起来都不错,现在我正在使用“简单身份验证和授权应用程序”(http://book.cakephp.org/2.0/en/tutorials-and-examples/blog-auth-example/auth.html)教程,但是遇到了这个问题。

  1. 添加页面加载正常:

    “... /应用程序/根目录/ index.php的/用户/添加”

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

    “... /应用程序/根目录/ index.php的/用户/用户/添加”

    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() {
    
    }
    
    }
    
  3. 请告诉我应该从哪里开始检查,谢谢。


    AppController的

        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;
          }
        }
    

1 个答案:

答案 0 :(得分:1)

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

AuthComponent中显示您的AppController.php配置。

编辑:

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

相关问题