Skip to content

NOW MANAGED ON CODEBERG

Updated guest settings system to format value as per non-guest

Dan Brownd62d2384cb88
diff --git a/app/Settings/SettingService.php b/app/Settings/SettingService.php
index 489963aad..dede8fcc4 100644
--- a/app/Settings/SettingService.php
+++ b/app/Settings/SettingService.php
@@ -4,10 +4,8 @@ use Illuminate\Contracts\Cache\Repository as Cache;
/**
* Class SettingService
- *
* The settings are a simple key-value database store.
- *
- * @package BookStack\Services
+ * For non-authenticated users, user settings are stored via the session instead.
*/
class SettingService
{
@@ -52,6 +50,19 @@ class SettingService
return $formatted;
}
+ /**
+ * Get a value from the session instead of the main store option.
+ * @param $key
+ * @param bool $default
+ * @return mixed
+ */
+ protected function getFromSession($key, $default = false)
+ {
+ $value = session()->get($key, $default);
+ $formatted = $this->formatValue($value, $default);
+ return $formatted;
+ }
+
/**
* Get a user-specific setting from the database or cache.
* @param \BookStack\Auth\User $user
@@ -62,7 +73,7 @@ class SettingService
public function getUser($user, $key, $default = false)
{
if ($user->isDefault()) {
- return session()->get($key, $default);
+ return $this->getFromSession($key, $default);
}
return $this->get($this->userKey($user->id, $key), $default);
}