Skip to content

Commit

Permalink
Fixing Auth's handling of params when loginAction is an array. Tests …
Browse files Browse the repository at this point in the history
…updated. Fixes #5961

git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@7972 3807eeeb-6ff5-0310-8944-8be069107fe0
  • Loading branch information
markstory committed Jan 6, 2009
1 parent 186a87b commit 6c258c0
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 19 deletions.
18 changes: 1 addition & 17 deletions cake/libs/controller/components/auth.php
Expand Up @@ -276,23 +276,7 @@ function startup(&$controller) {
$this->data = $controller->data = $this->hashPasswords($controller->data);
$url = '';

if (is_array($this->loginAction)) {
$params = $controller->params;
$keys = array('pass', 'named', 'controller', 'action', 'plugin');
$url = array();

foreach ($keys as $key) {
if (!empty($params[$key])) {
if (is_array($params[$key])) {
foreach ($params[$key] as $name => $value) {
$url[$name] = $value;
}
} else {
$url[$key] = $params[$key];
}
}
}
} elseif (isset($controller->params['url']['url'])) {
if (isset($controller->params['url']['url'])) {
$url = $controller->params['url']['url'];
}
$url = Router::normalize($url);
Expand Down
7 changes: 5 additions & 2 deletions cake/tests/cases/libs/controller/components/auth.test.php
Expand Up @@ -736,6 +736,7 @@ function testLoginRedirect() {
$this->Controller->Session->del('Auth');
$url = '/posts/index/year:2008/month:feb';
$this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';
Expand All @@ -747,6 +748,7 @@ function testLoginRedirect() {
$this->Controller->Session->del('Auth');
$url = '/posts/view/1';
$this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';
Expand All @@ -759,6 +761,7 @@ function testLoginRedirect() {
$this->Controller->Session->del('Auth');
$url = '/posts/edit/1';
$this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';
Expand All @@ -771,6 +774,7 @@ function testLoginRedirect() {
$this->Controller->Session->del('Auth');
$url = '/AuthTest/login';
$this->Controller->params = Router::parse($url);
$this->Controller->params['url']['url'] = Router::normalize($url);
$this->Controller->Auth->initialize($this->Controller);
$this->Controller->Auth->loginAction = array('controller' => 'AuthTest', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';
Expand Down Expand Up @@ -918,8 +922,7 @@ function testCustomRoute() {
$this->Controller->data['AuthUser'] = array('username' => 'felix', 'password' => 'cake');
$this->Controller->params['url']['url'] = substr($url, 1);
$this->Controller->Auth->initialize($this->Controller);

$this->Controller->Auth->loginAction = array('controller' => 'users', 'action' => 'login');
$this->Controller->Auth->loginAction = array('lang' => 'en', 'controller' => 'users', 'action' => 'login');
$this->Controller->Auth->userModel = 'AuthUser';

$this->Controller->Auth->startup($this->Controller);
Expand Down

0 comments on commit 6c258c0

Please sign in to comment.