Authenticating with email address in CakePHP v2.0

后端 未结 2 1598
有刺的猬
有刺的猬 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:31

    This is the best implementation I found: http://bin.cakephp.org/view/1831131032

    I like how some of the logic has been moved into the Model and clears up the Controller logic and makes it more MVC. Hopefully this will help others.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题