diff --git a/src/ZfcUser/Controller/UserController.php b/src/ZfcUser/Controller/UserController.php index e9bbd143..aae467e2 100644 --- a/src/ZfcUser/Controller/UserController.php +++ b/src/ZfcUser/Controller/UserController.php @@ -94,10 +94,10 @@ public function loginAction() $request = $this->getRequest(); $form = $this->getLoginForm(); - if ($this->getOptions()->getUseRedirectParameterIfPresent() && $request->getQuery()->get('redirect')) { - $redirect = $request->getQuery()->get('redirect'); - } else { - $redirect = false; + $redirect = false; + if ($this->getOptions()->getUseRedirectParameterIfPresent()) { + $redirect = $request->isPost() ? $request->getPost()->get('redirect') + : $request->getQuery()->get('redirect'); } if (!$request->isPost()) { diff --git a/tests/ZfcUserTest/Controller/UserControllerTest.php b/tests/ZfcUserTest/Controller/UserControllerTest.php index c08759f1..e12e3bc3 100644 --- a/tests/ZfcUserTest/Controller/UserControllerTest.php +++ b/tests/ZfcUserTest/Controller/UserControllerTest.php @@ -176,7 +176,7 @@ public function testLoginActionValidFormRedirectFalse($isValid, $wantRedirect) ->method('addMessage') ->will($this->returnSelf()); - $postArray = array('some', 'data'); + $postArray = new Parameters(array('some', 'data')); $request = $this->getMock('Zend\Http\Request'); $request->expects($this->any()) ->method('isPost') @@ -264,7 +264,7 @@ public function testLoginActionValidFormRedirectFalse($isValid, $wantRedirect) $url->expects($this->once()) ->method('fromRoute') ->with($controller::ROUTE_LOGIN) - ->will($this->returnValue($route_url)); + ->will($this->returnValue($route_url . $redirectQuery)); $this->pluginManagerPlugins['url']= $url; $TEST = true; @@ -301,8 +301,9 @@ public function testLoginActionIsNotPost($redirect) $this->pluginManagerPlugins['flashMessenger']= $flashMessenger; + $isPostTimes = $redirect ? 2 : 1; $request = $this->getMock('Zend\Http\Request'); - $request->expects($this->once()) + $request->expects($this->exactly($isPostTimes)) ->method('isPost') ->will($this->returnValue(false));