Skip to content

Commit

Permalink
Path resolution cleanup
Browse files Browse the repository at this point in the history
[ref: CWPBUG-158]
  • Loading branch information
Damian Mooyman committed May 5, 2014
1 parent f2b2ee8 commit d9bc352
Showing 1 changed file with 8 additions and 18 deletions.
26 changes: 8 additions & 18 deletions dev/DevelopmentAdmin.php
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -181,25 +181,15 @@ public function buildDefaults() {
public function generatesecuretoken() { public function generatesecuretoken() {
$generator = Injector::inst()->create('RandomGenerator'); $generator = Injector::inst()->create('RandomGenerator');
$token = $generator->randomToken('sha1'); $token = $generator->randomToken('sha1');
$body = <<<TXT
Generated new token. Please add the following code to your YAML configuration:
$path = $this->request->getVar('path'); Security:
if($path) { token: $token
if(file_exists(BASE_PATH . '/' . $path)) {
echo sprintf( TXT;
"Configuration file '%s' exists, can't merge. Please choose a new file.\n", $response = new SS_HTTPResponse($body);
BASE_PATH . '/' . $path return $response->addHeader('Content-Type', 'text/plain');
);
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";
}
} }


public function errors() { public function errors() {
Expand Down

0 comments on commit d9bc352

Please sign in to comment.