简体   繁体   English

Cakephp 2.4 Ajax登录

[英]Cakephp 2.4 Ajax Login

Not sure which part went wrong and tried to search through google for tutorial but no luck with the source out there. 不知道哪一部分出错了,并尝试通过google搜索教程,但没有运气,那里的源。 Basically whenever I try to submit the form, it check through chrome network and does the redirection to google.com even though the password is wrong. 基本上,每当我尝试提交表单时,即使密码错误,它也会通过chrome网络进行检查并重定向到google.com。 Anyone has clearer understand on cakephp auth to guide me through? 任何人对cakephp auth都有更清晰的了解,可以指导我进行操作?

Here is what I did 这是我所做的

AppController.php AppController.php

public $components = array('DebugKit.Toolbar',
                           'Session',
                           'Auth');

UsersController.php UsersController.php

public function login()
{
    if ($this->request->is('post')) 
    {
        $this->request->data['User']['username'] = $_POST['email'];
        $this->request->data['User']['password'] = $_POST['password'];

        if ($this->Auth->login()) 
        {
            $this->redirect('http://www.google.com');
        }
    }
}

I find out the reason redirecting keeps going through is that the previous user already logged in successfully. 我发现重定向持续进行的原因是先前的用户已经成功登录。 So what I do is providing the logout link and try again. 因此,我要做的是提供注销链接,然后重试。

public function logout() {
   return $this->redirect($this->Auth->logout());
}

Thanks again everyone. 再次感谢大家。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM