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');
|
||||
$token = $generator->randomToken('sha1');
|
||||
|
||||
echo <<<TXT
|
||||
|
||||
Token: $token
|
||||
|
||||
Please add this to your mysite/_config.php with the following code:
|
||||
Config::inst()->update('Security', 'token', '$token');
|
||||
|
||||
|
||||
TXT;
|
||||
$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";
|
||||
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() {
|
||||
|
Loading…
Reference in New Issue
Block a user