#5961: Custom route elements can't be used in loginAction
---------------------------+------------------------------------------------
    Reporter:  farhadi     |          Type:  Bug  
      Status:  new         |      Priority:  Low  
   Milestone:  1.2.x.x     |     Component:  Auth 
     Version:  1.2 Final   |      Severity:  Minor
    Keywords:  auth        |   Php_version:  PHP 5
Cake_version:  1.2.0.7962  |  
---------------------------+------------------------------------------------
 Hi,
 [[BR]]
 I have defined a route with a custom element:
 {{{
 Router::connect('/:lang/:controller/:action/*', array('lang' => null),
 array('lang'=>'[a-z]{2}'));
 }}}

 And I have set appropriate loginAction (in beforeFilter of AppController):
 {{{
 $this->Auth->loginAction = array('controller' => 'users', 'action' =>
 'login', 'lang' => $this->params['lang']);
 }}}

 And AuthComponent falls into a redirect loop in "/en/users/login" because
 it don't recognize that "/en/user/login" is the same as loginAction that I
 defined.

 [[BR]]
 I have provided a test case that demonstrates this issue:
 {{{
 function testCustomRouteElement() {
                 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->Controller->params['url']['url'] = substr($url, 1);
                 $this->Controller->Auth->initialize($this->Controller);

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

                 $this->Controller->Auth->startup($this->Controller);
                 $this->assertNull($this->Controller->testUrl);
         }
 }}}

 By the way, there is a workaround by using a string as loginAction instead
 of an array and it will work as expected.

-- 
Ticket URL: <https://trac.cakephp.org/ticket/5961>
CakePHP : The Rapid Development Framework for PHP <https://trac.cakephp.org/>
Cake is a rapid development framework for PHP which uses commonly known design 
patterns like ActiveRecord, Association Data Mapping, Front Controller and MVC. 
Our primary goal is to provide a structured framework that enables PHP users at 
all levels to rapidly develop robust web applications, without any loss to 
flexibility.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"tickets cakephp" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/tickets-cakephp?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to