Skip to content
This repository has been archived by the owner on Oct 10, 2018. It is now read-only.

Commit

Permalink
Move logout into user account widget
Browse files Browse the repository at this point in the history
  • Loading branch information
bjuppa committed Oct 4, 2018
1 parent 66dd53e commit 5683853
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
5 changes: 0 additions & 5 deletions resources/views/layouts/master.blade.php
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,6 @@

@section('body')
<header data-kontour-section="{{ $view_manager->headerSection() }}">
{{-- TODO: make this logout form part of a user-widget --}}
<form action="{{ route('kontour.logout') }}" method="post">
{{ csrf_field() }}
<button type="submit">Logout</button>
</form>
@foreach($widget_manager->getWidgetsForSection($view_manager->headerSection()) as $widget)
{{ $widget }}
@endforeach
Expand Down
5 changes: 5 additions & 0 deletions resources/views/widgets/userAccount.blade.php
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
<section data-kontour-widget="userAccount">
<span>{{ $user->getDisplayName() }}</span>
<form action="{{ route('kontour.logout') }}" method="post">
{{ csrf_field() }}
<button type="submit">Logout</button>
</form>
</section>
2 changes: 1 addition & 1 deletion src/Widgets/UserAccountWidget.php
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,6 @@ public function toHtml()

public function isAuthorized(Authorizable $user = null): bool
{
return true;
return (bool) $user;
}
}
3 changes: 2 additions & 1 deletion tests/Feature/UserlandControllerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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('<section data-kontour-widget="userAccount">');
$response->assertSee($this->user->getDisplayName());
$response->assertSee('<button type="submit">Logout</button>');
}

public function test_recent_visits_widgets()
Expand Down

0 comments on commit 5683853

Please sign in to comment.