Authenticating with email address in CakePHP v2.0

后端 未结 2 1621
有刺的猬
有刺的猬 2021-01-28 02:44

Okies this question is similar to one I have asked recently on Stack Overflow, but I\'m basically just using the code from the CakePHP Book rather than my own code to try and un

2条回答
  •  独厮守ぢ
    2021-01-28 03:39

    Though id added it in UsersController (not in AppController), but this worked for me for email as username:

    
    public $components = array('Auth');
    
    //beforeFilter in UsersController
    function beforeFilter() {
       parent::beforeFilter();
            $this->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
            $this->Auth->authenticate = array(
                'Form' => array(                
                    'fields' => array('username' => 'email')
                )
            );
    }
    
    

    Hope it helps in some way

提交回复
热议问题