/** * @group ZF-9859 */ public function testGotoUrlAndSetGotoUrlBehaveTheSame() { $url = 'http://www.example.com'; $gotoUrl = $this->redirector->gotoUrl($url); $setGotoUrl = $this->redirector->setGotoUrl($url); $this->assertSame($gotoUrl, $setGotoUrl); }
public function testSetGotoUrlWithHttpCodeUsingCodeOption() { $this->redirector->setGotoUrl('/foo/bar', array('code' => 301)); $this->assertEquals('/foo/bar', $this->redirector->getRedirectUrl()); $this->assertEquals(301, $this->response->getHttpResponseCode()); }
public function processAction() { $request = $this->getRequest(); // Check if we have a POST request if (!$request->isPost()) { return $this->_helper->redirector('index'); } // Get our form and validate it $form = $this->getForm(); if (!$form->isValid($request->getPost())) { // Invalid entries $this->view->form = $form; return $this->render('index'); } //check wether the user is active rather confirmed $dbAdapter = Zend_Registry::get('DB_CONNECTION1'); $userSelect = $dbAdapter->select(); $userSelect->from(User::TABLE_NAME); $userSelect->where(User::COL_USERNAME . '=?', $form->getValue(User::COL_EMAIL)); $userResult = $dbAdapter->fetchAll($userSelect); if ($userResult == array() || intval($userResult[0][User::COL_ACTIVE]) == 0) { $form->setDescription('Please confirm your account or inform the admin.'); $this->view->form = $form; return $this->render('index'); // re-render the login form } // Get our authentication adapter and check credentials $adapter = $this->getAuthAdapter($form->getValues()); $auth = Zend_Auth::getInstance(); $result = $auth->authenticate($adapter); if (!$result->isValid()) { // Invalid credentials $form->setDescription("Username or password doesn't match!"); $this->view->form = $form; return $this->render('index'); // re-render the login form } $auth->getStorage()->write($adapter->getResultRowObject()); $namespace = new Zend_Session_Namespace('default'); $namespace->auth = $auth; // We're authenticated! $Redirect = new Zend_Controller_Action_Helper_Redirector(); $returnUrl = str_replace(' ', '/', $this->getRequest()->getParam('returnUrl')); $defaultNamespace = new Zend_Session_Namespace('default'); foreach ($defaultNamespace->userParams as $key => $value) { $userParamsUrl = '/' . $key . '/' . $value; } $Redirect->setGotoUrl($returnUrl . $userParamsUrl); }