Centralized isLive checks
This commit is contained in:
parent
db290a1cf9
commit
4e75488dd3
|
@ -12,7 +12,10 @@ class TestSessionController extends Controller {
|
|||
public function init() {
|
||||
parent::init();
|
||||
|
||||
$canAccess = (Director::isDev() || Director::is_cli() || Permission::check("ADMIN"));
|
||||
$canAccess = (
|
||||
!Director::isLive()
|
||||
&& (Director::isDev() || Director::is_cli() || Permission::check("ADMIN"))
|
||||
);
|
||||
if(!$canAccess) return Security::permissionFailure($this);
|
||||
}
|
||||
|
||||
|
@ -29,7 +32,6 @@ class TestSessionController extends Controller {
|
|||
* as an encrypted cookie.
|
||||
*/
|
||||
public function start() {
|
||||
if(!Director::isLive()) {
|
||||
if(SapphireTest::using_temp_db()) {
|
||||
$endLink = Director::baseURL() . "dev/testsession/end";
|
||||
return "<p><a id=\"end-session\" href=\"$endLink\">You're in the middle of a test session;"
|
||||
|
@ -39,11 +41,11 @@ class TestSessionController extends Controller {
|
|||
$me = Director::baseURL() . "dev/testsession/start";
|
||||
return <<<HTML
|
||||
<form action="$me">
|
||||
<p>Enter a fixture file name to start a new test session. Don't forget to visit dev/testsession/end when
|
||||
you're done!</p>
|
||||
<p>Fixture file (leave blank to start with default set-up): <input id="fixture-file" name="fixture" /></p>
|
||||
<input type="hidden" name="flush" value="1">
|
||||
<p><input id="start-session" value="Start test session" type="submit" /></p>
|
||||
<p>Enter a fixture file name to start a new test session. Don't forget to visit dev/testsession/end when
|
||||
you're done!</p>
|
||||
<p>Fixture file (leave blank to start with default set-up): <input id="fixture-file" name="fixture" /></p>
|
||||
<input type="hidden" name="flush" value="1">
|
||||
<p><input id="start-session" value="Start test session" type="submit" /></p>
|
||||
</form>
|
||||
HTML;
|
||||
} else {
|
||||
|
@ -91,10 +93,6 @@ HTML;
|
|||
End your test session</a></li>
|
||||
</ul>";
|
||||
}
|
||||
|
||||
} else {
|
||||
return "<p>startession can only be used on dev and test sites</p>";
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -115,9 +113,6 @@ HTML;
|
|||
* as an encrypted cookie.
|
||||
*/
|
||||
public function setdb() {
|
||||
if(Director::isLive()) {
|
||||
return $this->httpError(403, "dev/testsession/setdb can only be used on dev and test sites");
|
||||
}
|
||||
if(!isset($_GET['database'])) {
|
||||
return $this->httpError(400, "dev/testsession/setdb must be used with a 'database' parameter");
|
||||
}
|
||||
|
@ -162,6 +157,7 @@ HTML;
|
|||
public function end() {
|
||||
SapphireTest::kill_temp_db();
|
||||
DB::set_alternative_database_name(null);
|
||||
Session::clear('testsession');
|
||||
|
||||
return "<p>Test session ended.</p>
|
||||
<ul>
|
||||
|
|
Loading…
Reference in New Issue