Showing
5 changed files
with
42 additions
and
21 deletions
| ... | @@ -13,6 +13,8 @@ class Kernel extends HttpKernel | ... | @@ -13,6 +13,8 @@ class Kernel extends HttpKernel |
| 13 | */ | 13 | */ |
| 14 | protected $middleware = [ | 14 | protected $middleware = [ |
| 15 | \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, | 15 | \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class, |
| 16 | + \Illuminate\Session\Middleware\StartSession::class, | ||
| 17 | + \Illuminate\View\Middleware\ShareErrorsFromSession::class, | ||
| 16 | ]; | 18 | ]; |
| 17 | 19 | ||
| 18 | /** | 20 | /** |
| ... | @@ -24,8 +26,6 @@ class Kernel extends HttpKernel | ... | @@ -24,8 +26,6 @@ class Kernel extends HttpKernel |
| 24 | 'web' => [ | 26 | 'web' => [ |
| 25 | \BookStack\Http\Middleware\EncryptCookies::class, | 27 | \BookStack\Http\Middleware\EncryptCookies::class, |
| 26 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, | 28 | \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class, |
| 27 | - \Illuminate\Session\Middleware\StartSession::class, | ||
| 28 | - \Illuminate\View\Middleware\ShareErrorsFromSession::class, | ||
| 29 | \BookStack\Http\Middleware\VerifyCsrfToken::class, | 29 | \BookStack\Http\Middleware\VerifyCsrfToken::class, |
| 30 | \Illuminate\Routing\Middleware\SubstituteBindings::class, | 30 | \Illuminate\Routing\Middleware\SubstituteBindings::class, |
| 31 | \BookStack\Http\Middleware\Localization::class | 31 | \BookStack\Http\Middleware\Localization::class | ... | ... |
| ... | @@ -38,6 +38,15 @@ function user() | ... | @@ -38,6 +38,15 @@ function user() |
| 38 | } | 38 | } |
| 39 | 39 | ||
| 40 | /** | 40 | /** |
| 41 | + * Check if current user is a signed in user. | ||
| 42 | + * @return bool | ||
| 43 | + */ | ||
| 44 | +function signedInUser() | ||
| 45 | +{ | ||
| 46 | + return auth()->user() && !auth()->user()->isDefault(); | ||
| 47 | +} | ||
| 48 | + | ||
| 49 | +/** | ||
| 41 | * Check if the current user has a permission. | 50 | * Check if the current user has a permission. |
| 42 | * If an ownable element is passed in the jointPermissions are checked against | 51 | * If an ownable element is passed in the jointPermissions are checked against |
| 43 | * that particular item. | 52 | * that particular item. | ... | ... |
| ... | @@ -55,15 +55,15 @@ | ... | @@ -55,15 +55,15 @@ |
| 55 | <div class="float right"> | 55 | <div class="float right"> |
| 56 | <div class="links text-center"> | 56 | <div class="links text-center"> |
| 57 | <a href="{{ baseUrl('/books') }}"><i class="zmdi zmdi-book"></i>{{ trans('entities.books') }}</a> | 57 | <a href="{{ baseUrl('/books') }}"><i class="zmdi zmdi-book"></i>{{ trans('entities.books') }}</a> |
| 58 | - @if(isset($currentUser) && userCan('settings-manage')) | 58 | + @if(signedInUser() && userCan('settings-manage')) |
| 59 | <a href="{{ baseUrl('/settings') }}"><i class="zmdi zmdi-settings"></i>{{ trans('settings.settings') }}</a> | 59 | <a href="{{ baseUrl('/settings') }}"><i class="zmdi zmdi-settings"></i>{{ trans('settings.settings') }}</a> |
| 60 | @endif | 60 | @endif |
| 61 | - @if(!isset($signedIn) || !$signedIn) | 61 | + @if(!signedInUser()) |
| 62 | <a href="{{ baseUrl('/login') }}"><i class="zmdi zmdi-sign-in"></i>{{ trans('auth.log_in') }}</a> | 62 | <a href="{{ baseUrl('/login') }}"><i class="zmdi zmdi-sign-in"></i>{{ trans('auth.log_in') }}</a> |
| 63 | @endif | 63 | @endif |
| 64 | </div> | 64 | </div> |
| 65 | - @if(isset($signedIn) && $signedIn) | 65 | + @if(signedInUser()) |
| 66 | - @include('partials._header-dropdown', ['currentUser' => $currentUser]) | 66 | + @include('partials._header-dropdown', ['currentUser' => user()]) |
| 67 | @endif | 67 | @endif |
| 68 | 68 | ||
| 69 | </div> | 69 | </div> | ... | ... |
| ... | @@ -10,22 +10,24 @@ | ... | @@ -10,22 +10,24 @@ |
| 10 | <p>{{ trans('errors.sorry_page_not_found') }}</p> | 10 | <p>{{ trans('errors.sorry_page_not_found') }}</p> |
| 11 | <p><a href="{{ baseUrl('/') }}" class="button">{{ trans('errors.return_home') }}</a></p> | 11 | <p><a href="{{ baseUrl('/') }}" class="button">{{ trans('errors.return_home') }}</a></p> |
| 12 | 12 | ||
| 13 | - <hr> | 13 | + @if (setting('app-public') || !user()->isDefault()) |
| 14 | - | 14 | + <hr> |
| 15 | - <div class="row"> | 15 | + |
| 16 | - <div class="col-md-4"> | 16 | + <div class="row"> |
| 17 | - <h3 class="text-muted">{{ trans('entities.pages_popular') }}</h3> | 17 | + <div class="col-md-4"> |
| 18 | - @include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Page::class]), 'style' => 'compact']) | 18 | + <h3 class="text-muted">{{ trans('entities.pages_popular') }}</h3> |
| 19 | - </div> | 19 | + @include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Page::class]), 'style' => 'compact']) |
| 20 | - <div class="col-md-4"> | 20 | + </div> |
| 21 | - <h3 class="text-muted">{{ trans('entities.books_popular') }}</h3> | 21 | + <div class="col-md-4"> |
| 22 | - @include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Book::class]), 'style' => 'compact']) | 22 | + <h3 class="text-muted">{{ trans('entities.books_popular') }}</h3> |
| 23 | - </div> | 23 | + @include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Book::class]), 'style' => 'compact']) |
| 24 | - <div class="col-md-4"> | 24 | + </div> |
| 25 | - <h3 class="text-muted">{{ trans('entities.chapters_popular') }}</h3> | 25 | + <div class="col-md-4"> |
| 26 | - @include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Chapter::class]), 'style' => 'compact']) | 26 | + <h3 class="text-muted">{{ trans('entities.chapters_popular') }}</h3> |
| 27 | + @include('partials.entity-list', ['entities' => Views::getPopular(10, 0, [\BookStack\Chapter::class]), 'style' => 'compact']) | ||
| 28 | + </div> | ||
| 27 | </div> | 29 | </div> |
| 28 | - </div> | 30 | + @endif |
| 29 | </div> | 31 | </div> |
| 30 | 32 | ||
| 31 | @stop | 33 | @stop |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
| ... | @@ -80,4 +80,14 @@ class PublicActionTest extends BrowserKitTest | ... | @@ -80,4 +80,14 @@ class PublicActionTest extends BrowserKitTest |
| 80 | ]); | 80 | ]); |
| 81 | } | 81 | } |
| 82 | 82 | ||
| 83 | + public function test_content_not_listed_on_404_for_public_users() | ||
| 84 | + { | ||
| 85 | + $page = \BookStack\Page::first(); | ||
| 86 | + $this->asAdmin()->visit($page->getUrl()); | ||
| 87 | + Auth::logout(); | ||
| 88 | + view()->share('pageTitle', ''); | ||
| 89 | + $this->forceVisit('/cats/dogs/hippos'); | ||
| 90 | + $this->dontSee($page->name); | ||
| 91 | + } | ||
| 92 | + | ||
| 83 | } | 93 | } |
| ... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
-
Please register or sign in to post a comment