Permalink
Browse files

FIX: Ensure that Security views respect redirections triggered by Pag…

…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...
1 parent f546979 commit 5f9348b0162fac4cd88d4d7b790d9f89e6c05ded @sminnee sminnee committed with chillu Aug 18, 2011
Showing with 11 additions and 2 deletions.
  1. +11 −2 security/Security.php
View
@@ -347,7 +347,6 @@ public function login() {
}
}
-
$customCSS = project() . '/css/tabs.css';
if(Director::fileExists($customCSS)) {
Requirements::css($customCSS);
@@ -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();
@@ -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>' .
@@ -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(
@@ -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'])) {

0 comments on commit 5f9348b

Please sign in to comment.