Permalink
Browse files

Path resolution cleanup

Backport of #3085 to 3.0
  • Loading branch information...
1 parent ddae582 commit 9bfeffd06a9e6ebc599ac671401b7e255e863534 @tractorcow tractorcow committed May 1, 2014
Showing with 9 additions and 18 deletions.
  1. +9 −18 dev/DevelopmentAdmin.php
View
@@ -184,25 +184,16 @@ public function buildDefaults() {
public function generatesecuretoken() {
$generator = Injector::inst()->create('RandomGenerator');
$token = $generator->randomToken('sha1');
+ $body = <<<TXT
+Generated new token. Please add the following code to your YAML configuration:
- $path = $this->request->getVar('path');
- if($path) {
- if(file_exists(BASE_PATH . '/' . $path)) {
- echo sprintf(
- "Configuration file '%s' exists, can't merge. Please choose a new file.\n",
- BASE_PATH . '/' . $path
- );
- exit(1);
- }
- $yml = "Security:\n token: $token";
- Filesystem::makeFolder(dirname(BASE_PATH . '/' . $path));
- file_put_contents(BASE_PATH . '/' . $path, $yml);
- echo "Configured token in $path\n";
- } else {
- echo "Generated new token. Please add the following code to your YAML configuration:\n\n";
- echo "Security:\n";
- echo " token: $token\n";
- }
+Security:
+ token: $token
+
+TXT;
+ $response = new SS_HTTPResponse($body);
+ $response->addHeader('Content-Type', 'text/plain');
+ return $response;
}
public function reset() {

0 comments on commit 9bfeffd

Please sign in to comment.