mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
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
This commit is contained in:
parent
186a87b514
commit
6c258c0f93
2 changed files with 6 additions and 19 deletions
|
@ -276,23 +276,7 @@ class AuthComponent extends Object {
|
|||
$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 @@ class AuthTest extends CakeTestCase {
|
|||
$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 @@ class AuthTest extends CakeTestCase {
|
|||
$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 @@ class AuthTest extends CakeTestCase {
|
|||
$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 @@ class AuthTest extends CakeTestCase {
|
|||
$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 @@ class AuthTest extends CakeTestCase {
|
|||
$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);
|
||||
|
|
Loading…
Reference in a new issue