FIX: Ensure that Security views respect redirections triggered by Page_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.
This commit is contained in:
Sam Minnee 2011-08-18 23:32:02 +12:00 committed by Ingo Schommer
parent f54697930e
commit 5f9348b016

View File

@ -347,7 +347,6 @@ class Security extends Controller {
} }
} }
$customCSS = project() . '/css/tabs.css'; $customCSS = project() . '/css/tabs.css';
if(Director::fileExists($customCSS)) { if(Director::fileExists($customCSS)) {
Requirements::css($customCSS); Requirements::css($customCSS);
@ -363,11 +362,12 @@ class Security extends Controller {
$controller = Page_Controller::create($tmpPage); $controller = Page_Controller::create($tmpPage);
$controller->setDataModel($this->model); $controller->setDataModel($this->model);
$controller->init(); $controller->init();
//Controller::$currentController = $controller;
} else { } else {
$controller = $this; $controller = $this;
} }
// if the controller calls Director::redirect(), this will break early
if(($response = $controller->getResponse()) && $response->isFinished()) return $response;
$content = ''; $content = '';
$forms = $this->GetLoginForms(); $forms = $this->GetLoginForms();
@ -461,6 +461,9 @@ class Security extends Controller {
$controller = $this; $controller = $this;
} }
// if the controller calls Director::redirect(), this will break early
if(($response = $controller->getResponse()) && $response->isFinished()) return $response;
$customisedController = $controller->customise(array( $customisedController = $controller->customise(array(
'Content' => 'Content' =>
'<p>' . '<p>' .
@ -520,6 +523,9 @@ class Security extends Controller {
$controller = $this; $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()); $email = Convert::raw2xml(rawurldecode($request->param('ID')) . '.' . $request->getExtension());
$customisedController = $controller->customise(array( $customisedController = $controller->customise(array(
@ -583,6 +589,9 @@ class Security extends Controller {
$controller = $this; $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. // Extract the member from the URL.
$member = null; $member = null;
if (isset($_REQUEST['m'])) { if (isset($_REQUEST['m'])) {