mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Direct writing of "Security.token" through dev/generatesecuretoken
This commit is contained in:
parent
4188668e68
commit
ced199b877
@ -181,15 +181,23 @@ class DevelopmentAdmin extends Controller {
|
|||||||
$generator = Injector::inst()->create('RandomGenerator');
|
$generator = Injector::inst()->create('RandomGenerator');
|
||||||
$token = $generator->randomToken('sha1');
|
$token = $generator->randomToken('sha1');
|
||||||
|
|
||||||
echo <<<TXT
|
$path = $this->request->getVar('path');
|
||||||
|
if($path) {
|
||||||
Token: $token
|
if(file_exists(BASE_PATH . '/' . $path)) {
|
||||||
|
echo sprintf(
|
||||||
Please add this to your mysite/_config.php with the following code:
|
"Configuration file '%s' exists, can't merge. Please choose a new file.\n",
|
||||||
Config::inst()->update('Security', 'token', '$token');
|
BASE_PATH . '/' . $path
|
||||||
|
);
|
||||||
|
exit(1);
|
||||||
TXT;
|
}
|
||||||
|
$yml = "Security:\n token: $token";
|
||||||
|
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 reset() {
|
public function reset() {
|
||||||
|
Loading…
Reference in New Issue
Block a user