Permalink
Browse files

Fixing Auth's handling of params when loginAction is an array. Tests …

…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...
1 parent 186a87b commit 6c258c0f930f2f107fb96781b00722a0c4de29b4 @markstory markstory committed Jan 6, 2009
@@ -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);
@@ -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';
@@ -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';
@@ -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';
@@ -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';
@@ -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);

0 comments on commit 6c258c0

Please sign in to comment.