Refactoring AuthComponent password hashing

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@4741 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
nate 2007-04-02 20:00:56 +00:00
parent 923303b462
commit 456baf5da1

View file

@ -674,21 +674,31 @@ class AuthComponent extends Object {
}
}
/**
* Hash any passwords found in Controller::$data.
* Hash any passwords found in $data using $userModel and $fields['password']
*
* @access public
* @param object $controller
* @return void
* @param array $data
* @return array
*/
function hashPasswords($data) {
if (isset($data[$this->userModel])) {
if (isset($data[$this->userModel][$this->fields['username']]) && isset($data[$this->userModel][$this->fields['password']])) {
$model =& $this->getUserModel();
$data[$this->userModel][$this->fields['password']] = Security::hash(CAKE_SESSION_STRING . $data[$this->userModel][$this->fields['password']]);
$data[$this->userModel][$this->fields['password']] = $this->password($data[$this->userModel][$this->fields['password']]);
}
}
return $data;
}
/**
* Hash a password with the application's salt value (as defined in CAKE_SESSION_STRING)
*
* @access public
* @param string $password
* @return string
*/
function password($password) {
return Security::hash(CAKE_SESSION_STRING . $password);
}
/**
* Component shutdown. If user is logged in, wipe out redirect.
*