Skip to content

Commit

Permalink
Merge pull request #918 from thnkloud9/zplus
Browse files Browse the repository at this point in the history
MOTM-851: Redirect user to the page they visited before logging in after...
  • Loading branch information
Paweł Mikołajczuk committed Dec 10, 2014
2 parents f6ffd48 + 8c3c9c9 commit 787a8e0
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
7 changes: 7 additions & 0 deletions newscoop/application/controllers/AuthController.php
Original file line number Diff line number Diff line change
Expand Up @@ -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"));
Expand Down Expand Up @@ -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) {
Expand Down
4 changes: 4 additions & 0 deletions newscoop/application/forms/Login.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down

0 comments on commit 787a8e0

Please sign in to comment.