1
0
Fork 0
mirror of https://github.com/sbrl/Pepperminty-Wiki.git synced 2024-11-24 17:13:01 +00:00

settings: fill in secret if it doesn't exist but peppermint.json does

This commit is contained in:
Starbeamrainbowlabs 2024-08-19 22:18:38 +01:00
parent 06d0fe4c5e
commit 9800c257de
Signed by: sbrl
GPG key ID: 1BE5172E637709C2
2 changed files with 6 additions and 4 deletions

View file

@ -8,6 +8,7 @@ This is the next release of Pepperminty Wiki, that hasn't been released yet.
- **Fixed:** Fixed link to the interwiki links documentation on the help page if interwiki links have not yet been setup. - **Fixed:** Fixed link to the interwiki links documentation on the help page if interwiki links have not yet been setup.
- **Fixed:** Fixed typos in system text - **Fixed:** Fixed typos in system text
- **Fixed:** Fixed handling of [`firstrun_complete`](https://starbeamrainbowlabs.com/labs/peppermint/peppermint-config-info.php#config_firstrun_complete) setting if `peppermint.json` is prefilled with a `firstrun_complete` directive but the Wiki hasn't been initialised for the first time yet - useful for installations inside Docker - **Fixed:** Fixed handling of [`firstrun_complete`](https://starbeamrainbowlabs.com/labs/peppermint/peppermint-config-info.php#config_firstrun_complete) setting if `peppermint.json` is prefilled with a `firstrun_complete` directive but the Wiki hasn't been initialised for the first time yet - useful for installations inside Docker
- **Fixed:** Fill in `secret` with a secrely random value inside `peppermint.json` if it doesn't exist.... even if `peppermint.json` already exists. Also useful for Docker users.
- **Changed:** Correctly check for `pdo_sqlite3` instead of `sqlite3` in `feature-firstrun` - **Changed:** Correctly check for `pdo_sqlite3` instead of `sqlite3` in `feature-firstrun`
- **Changed:** Catch and deal with more unpacking issues on first run (thanks, @daveschroeter in [#249](https://github.com/sbrl/Pepperminty-Wiki/issues/249)) - **Changed:** Catch and deal with more unpacking issues on first run (thanks, @daveschroeter in [#249](https://github.com/sbrl/Pepperminty-Wiki/issues/249))

View file

@ -37,8 +37,6 @@ if(!file_exists($settingsFilename)) {
// Copy the default settings over to the main settings array // Copy the default settings over to the main settings array
foreach ($guiConfig as $key => $value) foreach ($guiConfig as $key => $value)
$settings->$key = $value->default; $settings->$key = $value->default;
// Generate a random secret
$settings->secret = bin2hex(random_bytes(16));
if(file_put_contents("peppermint.json", json_encode($settings, JSON_PRETTY_PRINT)) === false) { if(file_put_contents("peppermint.json", json_encode($settings, JSON_PRETTY_PRINT)) === false) {
http_response_code(503); http_response_code(503);
header("content-type: text/plain"); header("content-type: text/plain");
@ -65,6 +63,9 @@ foreach($guiConfig as $key => $propertyData) {
$did_upgrade_firstrun_key = true; $did_upgrade_firstrun_key = true;
} }
} }
// Generate a random secret if it doesn't already exist
if(!property_exists($settings, "secret"))
$settings->secret = bin2hex(random_bytes(16));
if($settings_upgraded) if($settings_upgraded)
file_put_contents("peppermint.json", json_encode($settings, JSON_PRETTY_PRINT)); file_put_contents("peppermint.json", json_encode($settings, JSON_PRETTY_PRINT));