Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix not redirecting to URL #649

Open
wants to merge 1 commit into
base: 1.x
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 29 additions & 4 deletions src/ZfcUser/Controller/RedirectCallback.php
Original file line number Diff line number Diff line change
Expand Up @@ -74,14 +74,34 @@ private function getRedirectRouteFromRequest()
* @param $route
* @return bool
*/
private function routeExists($route)
private function routeExists($route)
{
// first check if such rout/name exists
// will throw exception if does not exist
$namedRouteMatch=0;
$urlRouteMatch=0;
try{
$this->router->assemble(array(), array('name' => $route));
}catch (Exception\RuntimeException $e) {
// didnt' match with any route name
$match=0;
}

// now try to match url with routes
try {
$this->router->assemble(array(), array('name' => $route));
$request=$this->application->getRequest();
$request->setUri($route);
$matchedRoute = $this->router->match($request);
if($matchedRoute){
$urlRouteMatch=1;
}
} catch (Exception\RuntimeException $e) {
return false;
$urlRouteMatch=0;
}
// check if anyof them matched
if($namedRouteMatch || $urlRouteMatch){
return true;
}
}

/**
Expand All @@ -104,7 +124,12 @@ protected function getRedirect($currentRoute, $redirect = false)
case 'zfcuser/register':
case 'zfcuser/login':
case 'zfcuser/authenticate':
$route = ($redirect) ?: $this->options->getLoginRedirectRoute();
// if redirect is there and matches a route just return it
if($redirect){
return $redirect;
}
// since its route name asseble and return string url
$route =$this->options->getLoginRedirectRoute();
return $this->router->assemble(array(), array('name' => $route));
break;
case 'zfcuser/logout':
Expand Down