By default in CakePHP 2.0, the authentication component make use of 2 fields to authenticate a user: username & password
If your web application requires user to login using email instead of a username, you can add in the following code snippet in the respective controller:
1 2 3 4 5 6 7 8 | public $components = array( 'authenticate' => array( 'Form' => array( 'fields' => array('username' => 'email') ) ) ) ); |
Take note that $components is a variable instead of a function under a controller.
Explanation: In the above code snippet, the email posted by the form will be taken as the username for the authentication component. The authentication component will then authenticate the user using email when $this->Auth->login() is called.
For more info, please refer to CakePHP 2.0 authentication component.























