mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 03:18:26 +00:00
Added check in AuthComponent::hashPasswords() to ensure that data is an array. Tests Added.
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7492 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
ce8dccc1fc
commit
9895f6d39b
2 changed files with 37 additions and 1 deletions
|
@ -793,7 +793,7 @@ class AuthComponent extends Object {
|
|||
return $this->authenticate->hashPasswords($data);
|
||||
}
|
||||
|
||||
if (isset($data[$this->userModel])) {
|
||||
if (is_array($data) && isset($data[$this->userModel])) {
|
||||
if (isset($data[$this->userModel][$this->fields['username']]) && isset($data[$this->userModel][$this->fields['password']])) {
|
||||
$data[$this->userModel][$this->fields['password']] = $this->password($data[$this->userModel][$this->fields['password']]);
|
||||
}
|
||||
|
|
|
@ -28,6 +28,8 @@
|
|||
*/
|
||||
App::import(array('controller' . DS . 'components' . DS .'auth', 'controller' . DS . 'components' . DS .'acl'));
|
||||
App::import(array('controller'.DS.'components'.DS.'acl', 'model'.DS.'db_acl'));
|
||||
App::import('Core', 'Xml');
|
||||
|
||||
Configure::write('Security.salt', 'JfIxfs2guVoUubWDYhG93b0qyJfIxfs2guwvniR2G0FgaC9mi');
|
||||
/**
|
||||
* Short description for class.
|
||||
|
@ -765,6 +767,40 @@ class AuthTest extends CakeTestCase {
|
|||
$this->Controller->Auth->startup($this->Controller);
|
||||
$this->assertTrue(is_null($this->Controller->Auth->user()));
|
||||
}
|
||||
/**
|
||||
* test Hashing of passwords
|
||||
*
|
||||
* @return void
|
||||
**/
|
||||
function testHashPasswords() {
|
||||
$this->Controller->Auth->userModel = 'AuthUser';
|
||||
|
||||
$data['AuthUser']['password'] = 'superSecret';
|
||||
$data['AuthUser']['username'] = 'superman@dailyplanet.com';
|
||||
$return = $this->Controller->Auth->hashPasswords($data);
|
||||
$expected = $data;
|
||||
$expected['AuthUser']['password'] = Security::hash($expected['AuthUser']['password'], null, true);
|
||||
$this->assertEqual($return, $expected);
|
||||
|
||||
$data['Wrong']['password'] = 'superSecret';
|
||||
$data['Wrong']['username'] = 'superman@dailyplanet.com';
|
||||
$data['AuthUser']['password'] = 'IcantTellYou';
|
||||
$return = $this->Controller->Auth->hashPasswords($data);
|
||||
$expected = $data;
|
||||
$expected['AuthUser']['password'] = Security::hash($expected['AuthUser']['password'], null, true);
|
||||
$this->assertEqual($return, $expected);
|
||||
|
||||
$xml = array(
|
||||
'User' => array(
|
||||
'username' => 'batman@batcave.com',
|
||||
'password' => 'bruceWayne',
|
||||
)
|
||||
);
|
||||
$data = new Xml($xml);
|
||||
$return = $this->Controller->Auth->hashPasswords($data);
|
||||
$expected = $data;
|
||||
$this->assertEqual($return, $expected);
|
||||
}
|
||||
/**
|
||||
* testCustomRoute method
|
||||
*
|
||||
|
|
Loading…
Reference in a new issue