1.3.4

I'm trying to dynamically set Auth's redirect route but something's
not right. The controller action's route:

Router::connect(
   '/galleries/:year/:month/:day/:slug',
   array(
           'controller' => 'galleries',
           'action' => 'slug'
   ),
   array(
           'year' => '2[0-9]{3}',
           'month' => '0[1-9]|1[012]',
           'day' => '0[1-9]|1[0-9]|2[0-9]|3[01]',
           'slug' => '[-_a-z0-9]+',
           'pass' => array('year', 'month', 'day', 'slug')
   )
);

What I want to do is set the redirect route to the current action. The
reason being that, if a user is not logged in, they'll see a login
link instead of a comment button and I want them to be directed
straight back to this action/view after logging in. So, in the action:

$this->Session->write(
   'Auth.redirect',
   Router::parse($this->params['url']['url'])
);

This results in:

/galleries/slug/year:2010/month:07/day:13/slug:a_slug_here/pass:Array

So nothing is passed correctly to the action. What's with the "Array"?
In a flash of inspiration:

$route = Router::parse($this->params['url']['url']);
unset($route['pass']);

$this->Session->write(
        'Auth.redirect',
        $route
);

Voila! Works like a charm, if a little ungainly.

I'm wondering if Router should ignore a param named 'pass'. That would
make it impossible for a route to have a passed param named 'pass'.
But, come to think of it, it's already impossible:

Router::connect(
   '/foo/:bar/:slug/:pass',
   array(
           'controller' => 'foos',
           'action' => 'slug'
   ),
   array(
           'bar' => '[0-9]+',
           'slug' => '[-_a-z0-9]+',
           'pass' => '[some regexp here]',
           'pass' => array('bar', 'slug', 'pass')
   )
);

It's clearly already unworkable. So, should 'pass' be silently ignored?

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"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/cake-php?hl=en

Reply via email to