Is there a way I can have a plugin redirect the whole page when it is getting called through an AJAX request?
Here is the code I am using to redirect non-authenticated users to the login page.
public function dispatchLoopStartup(Zend_Controller_Request_Abstract $request) {
if ($request->getControllerName() != 'authentication') {
if (!Zend_Auth::getInstance()->hasIdentity()) {
$request->setControllerName('authentication');
$request->setActionName('login');
return;
}
}
}
This works for normal requests but I want it to redirect users to the login page when they make AJAX requests after they are logged out. Using what I have now it loads the HTML for the login page inside the HTML element that is designated to house the result of the AJAX request.
How can I have it redirect the browser to the login page instead of just loading the login page inside the current page?