Skip to content

Commit

Permalink
BUGFIX Allowing Security controller methods to work without Page or P…
Browse files Browse the repository at this point in the history
…age_Controller classes (now moved to 'cms' module)
  • Loading branch information
chillu committed Mar 29, 2011
1 parent d93025d commit e1b249d
Showing 1 changed file with 46 additions and 28 deletions.
74 changes: 46 additions & 28 deletions security/Security.php
Expand Up @@ -83,6 +83,8 @@ class Security extends Controller {
*/
protected static $wordlist = './wordlist.txt';

static $template = 'BlankPage';

/**
* Template thats used to render the pages.
*
Expand Down Expand Up @@ -339,15 +341,20 @@ public function login() {
Requirements::css($customCSS);
}

$tmpPage = new Page();
$tmpPage->Title = _t('Security.LOGIN', 'Log in');
$tmpPage->URLSegment = "Security";
// Disable ID-based caching of the log-in page by making it a random number
$tmpPage->ID = -1 * rand(1,10000000);
if(class_exists('SiteTree')) {
$tmpPage = new Page();
$tmpPage->Title = _t('Security.LOGIN', 'Log in');
$tmpPage->URLSegment = "Security";
// Disable ID-based caching of the log-in page by making it a random number
$tmpPage->ID = -1 * rand(1,10000000);

$controller = new Page_Controller($tmpPage);
$controller->init();
//Controller::$currentController = $controller;
} else {
$controller = $this;
}

$controller = new Page_Controller($tmpPage);
$controller->init();
//Controller::$currentController = $controller;

$content = '';
$forms = $this->GetLoginForms();
Expand Down Expand Up @@ -436,12 +443,16 @@ public function lostpassword() {
Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js');
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/effects.js');

$tmpPage = new Page();
$tmpPage->Title = _t('Security.LOSTPASSWORDHEADER', 'Lost Password');
$tmpPage->URLSegment = 'Security';
$tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children
$controller = new Page_Controller($tmpPage);
$controller->init();
if(class_exists('SiteTree')) {
$tmpPage = new Page();
$tmpPage->Title = _t('Security.LOSTPASSWORDHEADER', 'Lost Password');
$tmpPage->URLSegment = 'Security';
$tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children
$controller = new Page_Controller($tmpPage);
$controller->init();
} else {
$controller = $this;
}

$customisedController = $controller->customise(array(
'Content' =>
Expand Down Expand Up @@ -495,12 +506,16 @@ public function passwordsent($request) {
Requirements::javascript(SAPPHIRE_DIR . '/javascript/prototype_improvements.js');
Requirements::javascript(SAPPHIRE_DIR . '/thirdparty/scriptaculous/effects.js');

$tmpPage = new Page();
$tmpPage->Title = _t('Security.LOSTPASSWORDHEADER');
$tmpPage->URLSegment = 'Security';
$tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children
$controller = new Page_Controller($tmpPage);
$controller->init();
if(class_exists('SiteTree')) {
$tmpPage = new Page();
$tmpPage->Title = _t('Security.LOSTPASSWORDHEADER');
$tmpPage->URLSegment = 'Security';
$tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children
$controller = new Page_Controller($tmpPage);
$controller->init();
} else {
$controller = $this;
}

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

Expand Down Expand Up @@ -541,12 +556,16 @@ public static function getPasswordResetLink($autoLoginHash) {
* @return string Returns the "change password" page as HTML code.
*/
public function changepassword() {
$tmpPage = new Page();
$tmpPage->Title = _t('Security.CHANGEPASSWORDHEADER', 'Change your password');
$tmpPage->URLSegment = 'Security';
$tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children
$controller = new Page_Controller($tmpPage);
$controller->init();
if(class_exists('SiteTree')) {
$tmpPage = new Page();
$tmpPage->Title = _t('Security.CHANGEPASSWORDHEADER', 'Change your password');
$tmpPage->URLSegment = 'Security';
$tmpPage->ID = -1; // Set the page ID to -1 so we dont get the top level pages as its children
$controller = new Page_Controller($tmpPage);
$controller->init();
} else {
$controller = $this;
}

// First load with hash: Redirect to same URL without hash to avoid referer leakage
if(isset($_REQUEST['h']) && Member::member_from_autologinhash($_REQUEST['h'])) {
Expand Down Expand Up @@ -934,5 +953,4 @@ public static function default_login_dest() {
return self::$default_login_dest;
}

}
?>
}

0 comments on commit e1b249d

Please sign in to comment.