I am using a simple Zend_Auth setup to authenticate users for one of my applications, using a check in the preDispatch() method in a controller plugin. When anonymous users navigate 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'd prefer not to store $_SERVER['REQUEST_URI']
in the session. Personally, I'd find storing the entire Zend Request object to cleanest solution, but I am not sure if this is sensible and if this is the approach I should be taking.
Any thoughts?
Well redirecting or forwarding to the LoginController might not be the optimal way to bring an un-authenticated user to the login page. Instead at preDispatch you can grab the $request object and alter it by doing the following.
$request->setActionName('someaction');
$request->setControllerName('somecontroller');
At this point your original request in maintained yet the page is displaying the login page. Then you can alter your login controller to check to see if the current request location is the login controller or if it something else. If it is something else (the original request) on a successful login send them to that page.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With