diff --git a/newscoop/application/controllers/AuthController.php b/newscoop/application/controllers/AuthController.php index 7884bc89bc..cdb08877ac 100644 --- a/newscoop/application/controllers/AuthController.php +++ b/newscoop/application/controllers/AuthController.php @@ -34,6 +34,9 @@ public function indexAction() $result = $this->auth->authenticate($adapter); if ($result->getCode() == Zend_Auth_Result::SUCCESS) { + if (isset($values['_target_path'])) { + $this->_helper->redirector->gotoUrl($values['_target_path']); + } $this->_helper->redirector('index', 'dashboard'); } else { $form->addError($this->view->translate("Invalid credentials")); @@ -99,6 +102,10 @@ public function socialAction() if ($user->isPending()) { $this->_forward('confirm', 'register', 'default'); } else { + $request = $this->getRequest(); + if ($request->getParam('_target_path')) { + $this->_helper->redirector->gotoUrl($request->getParam('_target_path')); + } $this->_helper->redirector('index', 'dashboard'); } } catch (\Exception $e) { diff --git a/newscoop/application/forms/Login.php b/newscoop/application/forms/Login.php index d621107729..b616af7391 100644 --- a/newscoop/application/forms/Login.php +++ b/newscoop/application/forms/Login.php @@ -11,6 +11,10 @@ class Application_Form_Login extends Zend_Form { public function init() { + $this->addElement('hidden', '_target_path', array( + 'value' => $_SERVER['REQUEST_URI'], + )); + $this->addElement('text', 'email', array( 'label' => 'Email', 'required' => true,