How to redirect to the requested URI after authentication with Zend_Auth?

I am using the simple Zend_Auth configuration to authenticate users for one of my applications using the preDispatch () method check in the controller plugin . When anonymous users go to

/users/view/id/6

for example, they should be redirected to the above URI after authentication.

What is the best way to do this? I would prefer not to store $_SERVER['REQUEST_URI']in the session. Personally, I would find storing the entire Zend Request object for a clean solution, but I'm not sure how reasonable this is, and if this is the approach I should take.

Any thoughts?

+5
source share
2 answers

Redirecting or redirecting redirects to the LoginController may not be the best way to bring an unauthenticated user to the login page. Instead, in preDispatch, you can grab the $ request object and modify it by doing the following.

$request->setActionName('someaction');
$request->setControllerName('somecontroller');

At this point, your initial request in the saved page is shown on the login page. You can then change your login controller to check if the current location of the request is a login controller or if it is something else. If this is something else (the original request) upon successful login, send them to this page.

+1
source

, URI . - , Zend Request, , .

, . , Zend Request, , .

+1