X-Git-Url: http://source.bookstackapp.com/bookstack/blobdiff_plain/3acea12f1c0013be4f1e3994cae2ea662e43bb4e..refs/pull/1756/head:/app/Auth/User.php diff --git a/app/Auth/User.php b/app/Auth/User.php index 7ad14d9f0..bce418a74 100644 --- a/app/Auth/User.php +++ b/app/Auth/User.php @@ -53,13 +53,24 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon */ protected $permissions; + /** + * This holds the default user when loaded. + * @var null|User + */ + protected static $defaultUser = null; + /** * Returns the default public user. * @return User */ public static function getDefault() { - return static::where('system_name', '=', 'public')->first(); + if (!is_null(static::$defaultUser)) { + return static::$defaultUser; + } + + static::$defaultUser = static::where('system_name', '=', 'public')->first(); + return static::$defaultUser; } /**