5.2.5.4 hashPasswords
hashPasswords ($data)
This method checks if the $data contains the username and password fields as specified by the variable $fields indexed by the model name as specified by $userModel. If the $data array contains both the username and password, it hashes the password field in the array and returns the data array in the same format. This function should be used prior to insert or update calls of the user when the password field is affected.
$data['User']['username'] = 'me@me.com';
$data['User']['password'] = 'changeme';
$hashedPasswords = $this->Auth->hashPasswords($data);
pr($hashedPasswords);
/* returns:
Array
(
[User] => Array
(
[username] => me@me.com
[password] => 8ed3b7e8ced419a679a7df93eff22fae
)
)
*/
$data['User']['username'] = 'me@me.com';$data['User']['password'] = 'changeme';$hashedPasswords = $this->Auth->hashPasswords($data);pr($hashedPasswords);/* returns:Array([User] => Array([username] => me@me.com[password] => 8ed3b7e8ced419a679a7df93eff22fae))*/
The $hashedPasswords['User']['password'] field would now be hashed using the password function of the component.
If your controller uses the Auth component and posted data contains the fields as explained above, it will automatically hash the password field using this function.


























