小编boi*_*dil的帖子

CakePHP 2.3.2 BasicAuthentication无效

我尝试了位于http://book.cakephp.org/2.0/en/tutorials-and-examples/simple-acl-controlled-application/simple-acl-controlled-application的"Simple Acl受控应用程序1和2"教程. HTML.

执行此操作后,我尝试激活BasicAuth而不是FormAuth.

我在我的UsersController中重新实现了login()函数,如下所示:

public function login() {
if ($this->Auth->login()) {
        return $this->redirect($this->Auth->redirect());
    } else {
        $this->Session->setFlash('Not able to login');
    }
}
Run Code Online (Sandbox Code Playgroud)

并将我的AppController中的$ components变量更改为以下内容:

public $components = array(
    'Acl',
    'Auth' => array(
        'authorize' => array(
            'Actions' => array('actionPath' => 'controllers')
        ),
        'authenticate' => array('Basic')
    ),
    'DebugKit.Toolbar',
    'Session'
);
Run Code Online (Sandbox Code Playgroud)

BasicAuth"弹出窗口"按预期显示,但是当我尝试登录时,它会在无限循环中重新启动.除了包含DebugKit之外,我在完成教程后没有做任何改动.

我错过了什么?我希望有人可以帮助我,因为我想在下一个项目中使用CakePHP编码!

更新

AppController的

public function beforeFilter() {
    //Configure AuthComponent
    $this->Auth->allow('display');
    $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
    $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login'); …
Run Code Online (Sandbox Code Playgroud)

cakephp basic-authentication cakephp-2.3

5
推荐指数
1
解决办法
4853
查看次数