1

我正在使用 cakePHP 2,当我的一位客户尝试登录应用程序时,我遇到了一个奇怪的问题。所以故事是这样的:她在数据库中设置了一个帐户,我可以使用她的帐户信息登录,但她不能。她没有显示错误(例如错误的电子邮件/密码)。当她按下登录时,她再次点击登录表单。

所以,在我的 AppController.php

public $components = array(
    'Acl',
    'Auth' => array(
                'authorize' => array('Actions' => array('actionPath' => 'controllers')),
                'authenticate' => array('Form' => array('fields' => array('username' => 'email')))
    ),
    'RequestHandler',
    'Session'
);

public function beforeFilter() {
    $group = $this->Auth->user('Group.name');
    $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
    $this->Auth->logoutRedirect = array('controller' => 'users', 'action' => 'login');

    if ($group == 'customer') {
        $this->layout = "customer";
        $this->Auth->loginRedirect = array('controller' => 'overviews', 'action' => 'index');
    }
    else {
        $this->layout = "default";
        $this->Auth->loginRedirect = array('controller' => 'pages', 'action' => 'index');
    }
 }

在我的 Config/core.php

Configure::write('Session', array(
    'defaults'          => 'cake',
    'checkAgent'        => false,
    'timeout'           => '120',
));


Configure::write('Security.level', 'low');

我真的不知道问题可能出在哪里......我无法在我自己的计算机上重现该问题。

编辑:UsersController.php 登录()

public function login() {
    $this->layout = 'login';
    if ($this->request->is('post')) {
        if ($this->Auth->login()) {
        $this->redirect(array('controller' => 'pages', 'action' => 'index'));

        } else {
            $this->Session->setFlash('Vos identifiants sont incorrectes.');
        }
    }
}
4

1 回答 1

0

尝试从登录操作中删除手动重定向:

$this->redirect(array('controller' => 'pages', 'action' => 'index'));

您已经设置loginRedirect了 Auth 组件的属性。

否则这很奇怪。要求用户清除所有浏览器缓存 - cookie + 缓存。还要检查tmp服务器上的所有目录是否可由 WebServer 用户写入 - 这包括系统tmp目录。

评论这篇文章,这样我们就可以继续尝试解决这个问题。它指向一个客户端问题,但你永远不知道。:D

于 2012-12-07T09:11:37.643 回答