return auth()->user() ?: \BookStack\User::getDefault();
}
+ /**
+ * Check if current user is a signed in user.
+ * @return bool
+ */
+ function signedInUser()
+ {
+ return auth()->user() && !auth()->user()->isDefault();
+ }
+
/**
* Check if the current user has a permission.
* If an ownable element is passed in the jointPermissions are checked against
*/
function setting($key = null, $default = false)
{
- $settingService = app(\BookStack\Services\SettingService::class);
+ $settingService = resolve(\BookStack\Services\SettingService::class);
if (is_null($key)) return $settingService;
return $settingService->get($key, $default);
}
return app('redirect')->to($to, $status, $headers, $secure);
}
+function icon($name, $attrs = []) {
+ $iconPath = resource_path('assets/icons/' . $name . '.svg');
+ $attrString = ' ';
+ foreach ($attrs as $attrName => $attr) {
+ $attrString .= $attrName . '="' . $attr . '" ';
+ }
+ $fileContents = file_get_contents($iconPath);
+ return str_replace('<svg', '<svg' . $attrString, $fileContents);
+}
+
/**
* Generate a url with multiple parameters for sorting purposes.
* Works out the logic to set the correct sorting direction
if (count($queryStringSections) === 0) return $path;
return baseUrl($path . '?' . implode('&', $queryStringSections));
-}
+}
-<?php
+<?php namespace Tests;
-class PublicActionTest extends TestCase
+class PublicActionTest extends BrowserKitTest
{
public function test_app_not_public()
]);
}
+ public function test_content_not_listed_on_404_for_public_users()
+ {
+ $page = \BookStack\Page::first();
+ $this->asAdmin()->visit($page->getUrl());
+ Auth::logout();
+ view()->share('pageTitle', '');
+ $this->forceVisit('/cats/dogs/hippos');
+ $this->dontSee($page->name);
+ }
+
}