mirror of
https://github.com/BookStackApp/BookStack.git
synced 2024-11-26 02:10:19 +08:00
Updated guest settings system to format value as per non-guest
Fixes #1431
This commit is contained in:
parent
a981dc41cb
commit
d62d2384cb
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user