mirror of
https://github.com/BookStackApp/BookStack.git
synced 2025-01-31 12:11:37 +01:00
Added options to allow whole site to be made public. Fixes #3.
This commit is contained in:
parent
a5807097e2
commit
ee8795dcda
@ -4,6 +4,7 @@ namespace Oxbow\Http\Middleware;
|
||||
|
||||
use Closure;
|
||||
use Illuminate\Contracts\Auth\Guard;
|
||||
use Setting;
|
||||
|
||||
class Authenticate
|
||||
{
|
||||
@ -33,7 +34,8 @@ class Authenticate
|
||||
*/
|
||||
public function handle($request, Closure $next)
|
||||
{
|
||||
if ($this->auth->guest()) {
|
||||
$sitePublic = Setting::get('app-public', false) === 'true';
|
||||
if ($this->auth->guest() && !$sitePublic) {
|
||||
if ($request->ajax()) {
|
||||
return response('Unauthorized.', 401);
|
||||
} else {
|
||||
|
@ -68,6 +68,9 @@ class User extends Model implements AuthenticatableContract, CanResetPasswordCon
|
||||
*/
|
||||
public function can($permissionName)
|
||||
{
|
||||
if($this->email == 'guest') {
|
||||
return false;
|
||||
}
|
||||
$permissions = $this->role->permissions()->get();
|
||||
$permissionSearch = $permissions->search(function ($item, $key) use ($permissionName) {
|
||||
return $item->name == $permissionName;
|
||||
|
@ -64,20 +64,22 @@
|
||||
<a href="/settings"><i class="zmdi zmdi-settings"></i>Settings</a>
|
||||
@endif
|
||||
</div>
|
||||
<img class="avatar" src="{{$currentUser->getAvatar(30)}}" alt="{{ $currentUser->name }}">
|
||||
<div class="dropdown-container" data-dropdown>
|
||||
<span class="user-name" data-dropdown-toggle>
|
||||
{{ $currentUser->name }} <i class="zmdi zmdi-caret-down"></i>
|
||||
</span>
|
||||
<ul class="dropdown">
|
||||
<li>
|
||||
<a href="/users/{{$currentUser->id}}" class="text-primary"><i class="zmdi zmdi-edit zmdi-hc-lg"></i>Edit Profile</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/logout" class="text-neg"><i class="zmdi zmdi-run zmdi-hc-lg"></i>Logout</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@if($signedIn)
|
||||
<img class="avatar" src="{{$currentUser->getAvatar(30)}}" alt="{{ $currentUser->name }}">
|
||||
<div class="dropdown-container" data-dropdown>
|
||||
<span class="user-name" data-dropdown-toggle>
|
||||
{{ $currentUser->name }} <i class="zmdi zmdi-caret-down"></i>
|
||||
</span>
|
||||
<ul class="dropdown">
|
||||
<li>
|
||||
<a href="/users/{{$currentUser->id}}" class="text-primary"><i class="zmdi zmdi-edit zmdi-hc-lg"></i>Edit Profile</a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="/logout" class="text-neg"><i class="zmdi zmdi-run zmdi-hc-lg"></i>Logout</a>
|
||||
</li>
|
||||
</ul>
|
||||
</div>
|
||||
@endif
|
||||
|
||||
</div>
|
||||
</div>
|
||||
|
@ -13,6 +13,11 @@
|
||||
<label for="setting-app-name">Application Name</label>
|
||||
<input type="text" value="{{ Setting::get('app-name') }}" name="setting-app-name" id="setting-app-name">
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<label for="setting-app-public">Allow public viewing?</label>
|
||||
<label><input type="radio" name="setting-app-public" @if(Setting::get('app-public') == 'true') checked @endif value="true"> Yes</label>
|
||||
<label><input type="radio" name="setting-app-public" @if(Setting::get('app-public') == 'false') checked @endif value="false"> No</label>
|
||||
</div>
|
||||
<div class="form-group">
|
||||
<button type="submit" class="button pos">Update Settings</button>
|
||||
</div>
|
||||
|
Loading…
x
Reference in New Issue
Block a user