/** * Returns the url to redirect to based on current route. * If $redirect is set and the option to use redirect is set to true, it * will return the $redirect url. * * @param string $currentRoute * @param bool $redirect * @return mixed */ protected function getRedirect($currentRoute, $redirect = false) { $useRedirect = $this->options->getUseRedirectParameterIfPresent(); $routeExists = $redirect && $this->routeExists($redirect); if (!$useRedirect || !$routeExists) { $redirect = false; } switch ($currentRoute) { case 'zfcuser/register': case 'zfcuser/login': case 'zfcuser/authenticate': if ($redirect && ($match = $this->routeExists($redirect)) == true) { $route = $match->getMatchedRouteName(); return $this->router->assemble(array(), array('name' => $route)); } else { $route = $this->options->getLoginRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); } break; case 'zfcuser/logout': $route = $redirect ?: $this->options->getLogoutRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); break; default: return $this->router->assemble(array(), array('name' => 'zfcuser')); } }
/** * Returns the url to redirect to based on current route. * If $redirect is set and the option to use redirect is set to true, it will return the $redirect url. * * @param string $currentRoute * @param bool $redirect * @return mixed */ private function getRedirect($currentRoute, $redirect = false) { $useRedirect = $this->options->getUseRedirectParameterIfPresent(); $routeExists = $redirect && $this->routeExists($redirect); if (!$useRedirect || !$routeExists) { $redirect = false; } switch ($currentRoute) { case 'zfcuser/login': case 'scn-social-auth-user/login': case 'scn-social-auth-user/register': case 'scn-social-auth-user/authenticate/provider': case 'scn-social-auth-user/add-provider/provider': $route = $redirect ?: $this->options->getLoginRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); break; case 'zfcuser/logout': case 'scn-social-auth-user/logout': $route = $redirect ?: $this->options->getLogoutRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); break; default: return $this->router->assemble(array(), array('name' => 'zfcuser')); } }
/** * Returns the url to redirect to based on current url. * If $redirect is set and the option to use redirect is set to true, it will return the $redirect url * after verifying that the url is in the whitelist. * * @param string $currentRoute * @param bool $redirect * @return mixed */ private function getRedirect($currentRoute, $redirect = false) { $useRedirect = $this->zfcUserOptions->getUseRedirectParameterIfPresent(); $urlAllowed = $redirect && $this->urlWhitelisted($redirect); if ($useRedirect && $urlAllowed) { return $redirect; } switch ($currentRoute) { case 'zfcuser/register': case 'zfcuser/login': $route = $this->zfcUserOptions->getLoginRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); break; case 'zfcuser/logout': $route = $this->zfcUserOptions->getLogoutRedirectRoute(); return $this->router->assemble(array(), array('name' => $route)); break; default: return $this->router->assemble(array(), array('name' => 'zfcuser')); } }
/** * @covers ZfcUser\Options\ModuleOptions::getUseRedirectParameterIfPresent */ public function testGetUseRedirectParameterIfPresent() { $this->assertTrue($this->options->getUseRedirectParameterIfPresent()); }