Updated guest settings system to format value as per non-guest
Fixes #1431
This commit is contained in:
parent
a981dc41cb
commit
d62d2384cb
1 changed files with 15 additions and 4 deletions
|
@ -4,10 +4,8 @@ use Illuminate\Contracts\Cache\Repository as Cache;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Class SettingService
|
* Class SettingService
|
||||||
*
|
|
||||||
* The settings are a simple key-value database store.
|
* The settings are a simple key-value database store.
|
||||||
*
|
* For non-authenticated users, user settings are stored via the session instead.
|
||||||
* @package BookStack\Services
|
|
||||||
*/
|
*/
|
||||||
class SettingService
|
class SettingService
|
||||||
{
|
{
|
||||||
|
@ -52,6 +50,19 @@ class SettingService
|
||||||
return $formatted;
|
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.
|
* Get a user-specific setting from the database or cache.
|
||||||
* @param \BookStack\Auth\User $user
|
* @param \BookStack\Auth\User $user
|
||||||
|
@ -62,7 +73,7 @@ class SettingService
|
||||||
public function getUser($user, $key, $default = false)
|
public function getUser($user, $key, $default = false)
|
||||||
{
|
{
|
||||||
if ($user->isDefault()) {
|
if ($user->isDefault()) {
|
||||||
return session()->get($key, $default);
|
return $this->getFromSession($key, $default);
|
||||||
}
|
}
|
||||||
return $this->get($this->userKey($user->id, $key), $default);
|
return $this->get($this->userKey($user->id, $key), $default);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue