Skip to content

Commit

Permalink
FIX: Ensure that Security views respect redirections triggered by Pag…
Browse files Browse the repository at this point in the history
…e_Controller::init()

Sometimes Page_Controller::init() will trigger a redirection.  For example, it may redirect to a
canonical URL.  In this case, the Security views, which co-opt Page_Controller, need to respect
this.
  • Loading branch information
Sam Minnee authored and chillu committed Jan 29, 2013
1 parent f546979 commit 5f9348b
Showing 1 changed file with 11 additions and 2 deletions.
13 changes: 11 additions & 2 deletions security/Security.php
Expand Up @@ -347,7 +347,6 @@ public function login() {
}
}


$customCSS = project() . '/css/tabs.css';
if(Director::fileExists($customCSS)) {
Requirements::css($customCSS);
Expand All @@ -363,11 +362,12 @@ public function login() {
$controller = Page_Controller::create($tmpPage);
$controller->setDataModel($this->model);
$controller->init();
//Controller::$currentController = $controller;
} else {
$controller = $this;
}

// if the controller calls Director::redirect(), this will break early
if(($response = $controller->getResponse()) && $response->isFinished()) return $response;

$content = '';
$forms = $this->GetLoginForms();
Expand Down Expand Up @@ -461,6 +461,9 @@ public function lostpassword() {
$controller = $this;
}

// if the controller calls Director::redirect(), this will break early
if(($response = $controller->getResponse()) && $response->isFinished()) return $response;

$customisedController = $controller->customise(array(
'Content' =>
'<p>' .
Expand Down Expand Up @@ -520,6 +523,9 @@ public function passwordsent($request) {
$controller = $this;
}

// if the controller calls Director::redirect(), this will break early
if(($response = $controller->getResponse()) && $response->isFinished()) return $response;

$email = Convert::raw2xml(rawurldecode($request->param('ID')) . '.' . $request->getExtension());

$customisedController = $controller->customise(array(
Expand Down Expand Up @@ -583,6 +589,9 @@ public function changepassword() {
$controller = $this;
}

// if the controller calls Director::redirect(), this will break early
if(($response = $controller->getResponse()) && $response->isFinished()) return $response;

// Extract the member from the URL.
$member = null;
if (isset($_REQUEST['m'])) {
Expand Down

0 comments on commit 5f9348b

Please sign in to comment.