]> BookStack Code Mirror - bookstack/blobdiff - app/Settings/SettingService.php
Add min length validation on name on register form & add sign up link
[bookstack] / app / Settings / SettingService.php
index c9491e3eeb4b4c949248680b9d43b1a0e45c3f59..489963aad7cde7b361ffdecfcb4e7d7edb4e3301 100644 (file)
@@ -61,9 +61,23 @@ class SettingService
      */
     public function getUser($user, $key, $default = false)
     {
+        if ($user->isDefault()) {
+            return session()->get($key, $default);
+        }
         return $this->get($this->userKey($user->id, $key), $default);
     }
 
+    /**
+     * Get a value for the current logged-in user.
+     * @param $key
+     * @param bool $default
+     * @return bool|string
+     */
+    public function getForCurrentUser($key, $default = false)
+    {
+        return $this->getUser(user(), $key, $default);
+    }
+
     /**
      * Gets a setting value from the cache or database.
      * Looks at the system defaults if not cached or in database.
@@ -180,6 +194,9 @@ class SettingService
      */
     public function putUser($user, $key, $value)
     {
+        if ($user->isDefault()) {
+            return session()->put($key, $value);
+        }
         return $this->put($this->userKey($user->id, $key), $value);
     }