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.
source
share