Hi all

When a user accesses a restricted page on my site and they have no identity
a plugin in preDispatch sets the controller to login and action to index to
render the page /login/index

This works fine. However I want to redirect to the url they were initially
trying to access after they login.

I was thinking of doing something like this in the plugin.

$request->setParam('redirectController', $request->getControllerName());
$request->setParam('redirectAction', $request->getActionName());

And then passing the data to a hidden field in my login form such as
redirectUrl.

This gets complicated though. If I want to pass any keys/values.

I could do something like this.

$request->setParam('redirectParams', $request->getParams());

But this won't work for everything as I am using custom routes that fuddle
up getParams(). Ie one of my routes overrides the
/controller/action/key/value/key/value scheme to
/controller/action/value1/value2/value3 and stores the values as an array in
its own param.

So really I can't simply just iterate through getParams to build my redirect
url.

I kind of want to access the requestUrl or pathInfo which I noticed is
protected in the request object.

Then I can simply use this to redirect after a login. Is this possible and
what is the difference between the two?

Does anybody have any ideas? Is there an alternate approach?

Hope this makes sense.

Thanks

Reply via email to