From 5683853898b08706c2c52d4ec2a0f9a09b28373b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B6rn=20Nilsved?= Date: Thu, 4 Oct 2018 16:33:39 +0200 Subject: [PATCH] Move logout into user account widget --- resources/views/layouts/master.blade.php | 5 ----- resources/views/widgets/userAccount.blade.php | 5 +++++ src/Widgets/UserAccountWidget.php | 2 +- tests/Feature/UserlandControllerTest.php | 3 ++- 4 files changed, 8 insertions(+), 7 deletions(-) diff --git a/resources/views/layouts/master.blade.php b/resources/views/layouts/master.blade.php index fb6fb0f..988d3f7 100644 --- a/resources/views/layouts/master.blade.php +++ b/resources/views/layouts/master.blade.php @@ -5,11 +5,6 @@ @section('body')
- {{-- TODO: make this logout form part of a user-widget --}} -
- {{ csrf_field() }} - -
@foreach($widget_manager->getWidgetsForSection($view_manager->headerSection()) as $widget) {{ $widget }} @endforeach diff --git a/resources/views/widgets/userAccount.blade.php b/resources/views/widgets/userAccount.blade.php index 2cad045..b002f8d 100644 --- a/resources/views/widgets/userAccount.blade.php +++ b/resources/views/widgets/userAccount.blade.php @@ -1,2 +1,7 @@
+ {{ $user->getDisplayName() }} +
+ {{ csrf_field() }} + +
diff --git a/src/Widgets/UserAccountWidget.php b/src/Widgets/UserAccountWidget.php index 63648bc..e103211 100644 --- a/src/Widgets/UserAccountWidget.php +++ b/src/Widgets/UserAccountWidget.php @@ -17,6 +17,6 @@ public function toHtml() public function isAuthorized(Authorizable $user = null): bool { - return true; + return (bool) $user; } } diff --git a/tests/Feature/UserlandControllerTest.php b/tests/Feature/UserlandControllerTest.php index 7b7d6b2..1793c86 100644 --- a/tests/Feature/UserlandControllerTest.php +++ b/tests/Feature/UserlandControllerTest.php @@ -54,8 +54,9 @@ public function test_menu_widget() public function test_user_account_widget() { $response = $this->actingAs($this->user)->get(route('userland.index')); - $response->assertSee('
'); + $response->assertSee($this->user->getDisplayName()); + $response->assertSee(''); } public function test_recent_visits_widgets()