diff --git a/core/i18nTextCollectorTask.php b/core/i18nTextCollectorTask.php index 558150eb9..bcd3031b7 100644 --- a/core/i18nTextCollectorTask.php +++ b/core/i18nTextCollectorTask.php @@ -13,8 +13,10 @@ class i18nTextCollectorTask extends BuildTask { "; function init() { - if(!Director::is_cli() && !Director::isDev() && !Permission::check("ADMIN")) Security::permissionFailure(); parent::init(); + + $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); + if(!$canAccess) return Security::permissionFailure($this); } /** diff --git a/dev/DevelopmentAdmin.php b/dev/DevelopmentAdmin.php index 03cb010db..8d609f5dc 100644 --- a/dev/DevelopmentAdmin.php +++ b/dev/DevelopmentAdmin.php @@ -21,16 +21,8 @@ class DevelopmentAdmin extends Controller { // We allow access to this controller regardless of live-status or ADMIN permission only // if on CLI. Access to this controller is always allowed in "dev-mode", or of the user is ADMIN. - $canAccess = ( - Director::isDev() - || Director::is_cli() - || Permission::check("ADMIN") - ); - if(!$canAccess) { - return Security::permissionFailure($this, - "This page is secured and you need administrator rights to access it. " . - "Enter your credentials below and we will send you right along."); - } + $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); + if(!$canAccess) return Security::permissionFailure($this); // check for valid url mapping // lacking this information can cause really nasty bugs, diff --git a/dev/ModelViewer.php b/dev/ModelViewer.php index 8159bb9f2..7acd22ae4 100644 --- a/dev/ModelViewer.php +++ b/dev/ModelViewer.php @@ -21,7 +21,9 @@ class ModelViewer extends Controller { function init() { parent::init(); - if(!Permission::check("ADMIN")) Security::permissionFailure(); + + $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); + if(!$canAccess) return Security::permissionFailure($this); // check for graphviz dependencies $returnCode = 0; diff --git a/dev/TaskRunner.php b/dev/TaskRunner.php index 6f07233c2..c5bdb347f 100644 --- a/dev/TaskRunner.php +++ b/dev/TaskRunner.php @@ -10,6 +10,13 @@ class TaskRunner extends Controller { '$TaskName' => 'runTask' ); + function init() { + parent::init(); + + $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); + if(!$canAccess) return Security::permissionFailure($this); + } + function index() { $tasks = $this->getTasks(); diff --git a/dev/TestRunner.php b/dev/TestRunner.php index 075a874a3..34894be68 100644 --- a/dev/TestRunner.php +++ b/dev/TestRunner.php @@ -59,6 +59,10 @@ class TestRunner extends Controller { function init() { parent::init(); + + $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); + if(!$canAccess) return Security::permissionFailure($this); + ManifestBuilder::load_test_manifest(); if (!self::$default_reporter) self::set_reporter(Director::is_cli() ? 'CliDebugView' : 'DebugView'); diff --git a/dev/TestViewer.php b/dev/TestViewer.php index 8ced0cd16..31dbda57c 100644 --- a/dev/TestViewer.php +++ b/dev/TestViewer.php @@ -66,6 +66,13 @@ class TestViewer extends Controller { '*' => array('', 'potentialMethodCall'), ), ); + + function init() { + parent::init(); + + $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); + if(!$canAccess) return Security::permissionFailure($this); + } function createClass($token) { $this->currentClass = array(); diff --git a/tasks/MigrateTranslatableTask.php b/tasks/MigrateTranslatableTask.php index 84bd55c76..19b941cdc 100644 --- a/tasks/MigrateTranslatableTask.php +++ b/tasks/MigrateTranslatableTask.php @@ -42,8 +42,10 @@ class MigrateTranslatableTask extends BuildTask { protected $description = "Migrates site translations from SilverStripe 2.1/2.2 to new database structure."; function init() { - if(!Director::is_cli() && !Director::isDev() && !Permission::check("ADMIN")) Security::permissionFailure(); parent::init(); + + $canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN")); + if(!$canAccess) return Security::permissionFailure($this); } function run($request) {