From 4e18491e7cca047bec39eaf473ca9d6b8185009f Mon Sep 17 00:00:00 2001 From: Vincent Vanwaelscappel Date: Wed, 15 May 2024 15:06:48 +0200 Subject: [PATCH] wait #6913 @1 --- app/Fluidbook/Compiler/Secure.php | 8 +++++--- app/Models/FluidbookPublication.php | 19 +++++++++++++++---- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/app/Fluidbook/Compiler/Secure.php b/app/Fluidbook/Compiler/Secure.php index 3f5bc39fd..add45a2c5 100644 --- a/app/Fluidbook/Compiler/Secure.php +++ b/app/Fluidbook/Compiler/Secure.php @@ -21,7 +21,9 @@ trait Secure protected function _getSecureUsers() { $credentials = Text::explodeNewLines(trim($this->fluidbookSettings->secureClientSidePasswordCredentials)); - if ($this->fluidbookSettings->secureClientSideMode == '1') { + $mode = $this->fluidbookSettings->secureClientSideMode ?? '0'; + + if ($mode == '1') { $credentials[] = 'fluidbook'; } else { $credentials[] = 'fluidbook:LatacaM4##*'; @@ -30,13 +32,13 @@ trait Secure foreach ($credentials as $credential) { $salt = bin2hex(random_bytes(5)); $e = explode(':', $credential); - if ($this->fluidbookSettings->secureClientSideMode == '0' && count($e) <= 1) { + if ($mode == '0' && count($e) <= 1) { continue; } $usersalt = bin2hex(random_bytes(5)); $user = hash("sha256", $usersalt . '+' . mb_strtolower($e[0])); $u = ['salt' => $salt, 'usersalt' => $usersalt]; - if (count($e) > 1 && $this->fluidbookSettings->secureClientSideMode != '0') { + if (count($e) > 1 && $mode == '0') { $u['hash'] = hash("sha256", $salt . '-' . Text::removeAccents($e[1])); } $users[$user] = $u; diff --git a/app/Models/FluidbookPublication.php b/app/Models/FluidbookPublication.php index 545468dce..90034e6a8 100644 --- a/app/Models/FluidbookPublication.php +++ b/app/Models/FluidbookPublication.php @@ -1033,6 +1033,12 @@ class FluidbookPublication extends ToolboxStatusModel return $res; } + public function onRetrieved(): bool + { + $this->setDefaults(); + return parent::onRetrieved(); + } + public function getAnchorsFromExcel() { $res = []; @@ -1117,7 +1123,15 @@ class FluidbookPublication extends ToolboxStatusModel $version = 3; } $this->version = $version; - $fields = ['imageFormat', 'secureClientSidePassword', 'relay_url_params']; + $this->setDefaults(); + $this->save(); + + DB::update('UPDATE ' . WorkshopMigration::OLD_DB . '.books SET version=' . $version . ' WHERE book_id=' . $this->id); + } + + public function setDefaults() + { + $fields = ['imageFormat', 'secureClientSidePassword', 'secureClientSideMode', 'relay_url_params']; foreach ($fields as $n) { $f = $this->getField($n); if (null === $this->{$n}) { @@ -1125,9 +1139,6 @@ class FluidbookPublication extends ToolboxStatusModel } } $this->svgToCanvas = !$this->svgToCanvas ? 0 : 1; - $this->save(); - - DB::update('UPDATE ' . WorkshopMigration::OLD_DB . '.books SET version=' . $version . ' WHERE book_id=' . $this->id); } public function generateThumbnailsPreview($sync = false) -- 2.39.5