mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2025-01-31 09:06:17 +00:00
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:
parent
923303b462
commit
456baf5da1
1 changed files with 14 additions and 4 deletions
|
@ -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.
|
||||
*
|
||||
|
|
Loading…
Add table
Reference in a new issue