mirror of
https://github.com/kamilwylegala/cakephp2-php8.git
synced 2024-11-15 11:28:25 +00:00
Improved AuthComponent to use an array to match the login action, fixes #4572
git-svn-id: https://svn.cakephp.org/repo/branches/1.2.x.x@6830 3807eeeb-6ff5-0310-8944-8be069107fe0
This commit is contained in:
parent
82d595551c
commit
451192018a
2 changed files with 28 additions and 0 deletions
|
@ -278,6 +278,10 @@ class AuthComponent extends Object {
|
|||
$url = $controller->params['url']['url'];
|
||||
}
|
||||
|
||||
if (is_array($this->loginAction)) {
|
||||
$this->loginAction = $this->loginAction['controller'].'/'.$this->loginAction['action'];
|
||||
$url = $controller->params['controller'].'/'.$controller->params['action'];
|
||||
}
|
||||
$this->loginAction = Router::normalize($this->loginAction);
|
||||
|
||||
if ($this->loginAction != Router::normalize($url) && ($this->allowedActions == array('*') || in_array($controller->action, $this->allowedActions))) {
|
||||
|
|
|
@ -416,6 +416,30 @@ class AuthTest extends CakeTestCase {
|
|||
$this->assertTrue(is_null($this->Controller->Auth->user()));
|
||||
}
|
||||
|
||||
function testCustomRoute() {
|
||||
Router::reload();
|
||||
Router::connect('/:lang/:controller/:action/*', array('lang' => null), array('lang' => '[a-z]{2,3}'));
|
||||
|
||||
$url = '/en/users/login';
|
||||
$this->Controller->params = Router::parse($url);
|
||||
Router::setRequestInfo(array($this->Controller->passedArgs, array('base' => null, 'here' => $url, 'webroot' => '/', 'passedArgs' => array(), 'argSeparator' => ':', 'namedArgs' => array())));
|
||||
|
||||
$this->AuthUser =& new AuthUser();
|
||||
$user = array('id' => 1, 'username' => 'felix', 'password' => Security::hash(Configure::read('Security.salt') . 'cake'));
|
||||
$user = $this->AuthUser->save($user, false);
|
||||
|
||||
$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->userModel = 'AuthUser';
|
||||
|
||||
$this->Controller->Auth->startup($this->Controller);
|
||||
$user = $this->Controller->Auth->user();
|
||||
$this->assertTrue(!!$user);
|
||||
}
|
||||
|
||||
function tearDown() {
|
||||
unset($this->Controller, $this->AuthUser);
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue