Skip to content

Commit

Permalink
Fixing case where it was possible to pass array data to FormAuthenticate
Browse files Browse the repository at this point in the history
fields
  • Loading branch information
lorenzo committed Apr 24, 2013
1 parent e144afe commit db6dd18
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 5 deletions.
10 changes: 5 additions & 5 deletions lib/Cake/Controller/Component/Auth/FormAuthenticate.php
Expand Up @@ -49,11 +49,11 @@ protected function _checkFields(CakeRequest $request, $model, $fields) {
if (empty($request->data[$model])) {
return false;
}
if (
empty($request->data[$model][$fields['username']]) ||
empty($request->data[$model][$fields['password']])
) {
return false;
foreach (array($fields['username'], $fields['password']) as $field) {
$value = $request->data($model . '.' . $field);
if (empty($value) || !is_string($value)) {
return false;
}
}
return true;
}
Expand Down
Expand Up @@ -115,6 +115,28 @@ public function testAuthenticatePasswordIsFalse() {
$this->assertFalse($this->auth->authenticate($request, $this->response));
}

/**
* test authenticate field is not string
*
* @return void
*/
public function testAuthenticateFieldsAreNotString() {
$request = new CakeRequest('posts/index', false);
$request->data = array(
'User' => array(
'user' => array('mariano', 'phpnut'),
'password' => 'my password'
));
$this->assertFalse($this->auth->authenticate($request, $this->response));

$request->data = array(
'User' => array(
'user' => 'mariano',
'password' => array('password1', 'password2')
));
$this->assertFalse($this->auth->authenticate($request, $this->response));
}

/**
* test the authenticate method
*
Expand Down

0 comments on commit db6dd18

Please sign in to comment.