diff --git a/app/Livewire/ManageAuthenticationTokens.php b/app/Livewire/ManageAuthenticationTokens.php index a7958c9..0fe23af 100644 --- a/app/Livewire/ManageAuthenticationTokens.php +++ b/app/Livewire/ManageAuthenticationTokens.php @@ -5,8 +5,10 @@ namespace App\Livewire; use App\Models\AuthenticationToken; use Illuminate\Support\Facades\Auth; use Livewire\Attributes\Computed; +use Livewire\Attributes\Layout; use Livewire\Component; +#[Layout('components.layouts.app')] class ManageAuthenticationTokens extends Component { #[Computed] @@ -37,6 +39,6 @@ class ManageAuthenticationTokens extends Component public function render() { - return view('livewire.manage-authentication-tokens'); + return view('livewire.manage-authentication-tokens')->title('Authentication Tokens'); } } diff --git a/resources/views/components/layouts/app/header.blade.php b/resources/views/components/layouts/app/header.blade.php index 7904c17..876d4b3 100644 --- a/resources/views/components/layouts/app/header.blade.php +++ b/resources/views/components/layouts/app/header.blade.php @@ -19,6 +19,10 @@ wire:navigate> {{ __('Apps') }} + + {{ __('Tokens') }} + @can('viewAny', App\Models\User::class) @@ -96,6 +100,10 @@ :current="request()->routeIs('dashboard')" wire:navigate> {{ __('Dashboard') }} + + {{ __('Tokens') }} + @can('viewAny', App\Models\User::class) diff --git a/resources/views/components/layouts/app/sidebar.blade.php b/resources/views/components/layouts/app/sidebar.blade.php index aa24e73..c6b04ba 100644 --- a/resources/views/components/layouts/app/sidebar.blade.php +++ b/resources/views/components/layouts/app/sidebar.blade.php @@ -14,6 +14,7 @@ {{ __('Dashboard') }} + {{ __('Tokens') }} @can('viewAny', App\Models\User::class) {{ __('User Management') }} @endcan diff --git a/resources/views/dashboard.blade.php b/resources/views/dashboard.blade.php index 1612bb3..1027a99 100644 --- a/resources/views/dashboard.blade.php +++ b/resources/views/dashboard.blade.php @@ -4,10 +4,6 @@ - - - - @can('viewAny', App\Models\Application::class) @@ -20,7 +16,7 @@ Welcome to AuthentiKate - You can manage your profile and view your authentication tokens above. + You can manage your profile above and view your authentication tokens in the Tokens section. diff --git a/resources/views/livewire/manage-authentication-tokens.blade.php b/resources/views/livewire/manage-authentication-tokens.blade.php index f267b4c..266bd6a 100644 --- a/resources/views/livewire/manage-authentication-tokens.blade.php +++ b/resources/views/livewire/manage-authentication-tokens.blade.php @@ -1,4 +1,4 @@ - + Authentication Tokens diff --git a/routes/web.php b/routes/web.php index 8531fca..4a2dc80 100644 --- a/routes/web.php +++ b/routes/web.php @@ -2,6 +2,7 @@ use App\Http\Controllers\OIDCController; use App\Livewire\ConsentScreen; +use App\Livewire\ManageAuthenticationTokens; use App\Livewire\ManageUsers; use App\Livewire\Settings\Appearance; use App\Livewire\Settings\Password; @@ -24,6 +25,10 @@ Route::get('admin/users', ManageUsers::class) ->middleware(['auth', 'can:viewAny,App\Models\User']) ->name('admin.users'); +Route::get('tokens', ManageAuthenticationTokens::class) + ->middleware(['auth']) + ->name('tokens'); + Route::middleware(['auth'])->group(function () { Route::redirect('settings', 'settings/profile'); diff --git a/tests/Feature/TokensPageTest.php b/tests/Feature/TokensPageTest.php new file mode 100644 index 0000000..4815e1d --- /dev/null +++ b/tests/Feature/TokensPageTest.php @@ -0,0 +1,69 @@ +admin = User::factory()->create(['is_admin' => true]); + $this->user = User::factory()->create(['is_admin' => false]); +}); + +describe('Tokens Page', function () { + + it('allows any authenticated user to access the tokens page', function () { + $this->actingAs($this->user); + + $response = $this->get(route('tokens')); + + $response->assertStatus(200); + $response->assertSee('Authentication Tokens'); + $response->assertSee('Manage your active authentication tokens'); + }); + + it('allows admin users to access the tokens page', function () { + $this->actingAs($this->admin); + + $response = $this->get(route('tokens')); + + $response->assertStatus(200); + $response->assertSee('Authentication Tokens'); + $response->assertSee('Manage your active authentication tokens'); + }); + + it('redirects unauthenticated users to login', function () { + $response = $this->get(route('tokens')); + + $response->assertRedirect(route('login')); + }); + + it('shows the tokens navigation link to all authenticated users', function () { + // Test regular user sees the link + $this->actingAs($this->user); + $response = $this->get(route('dashboard')); + $response->assertSee('Tokens'); + + // Test admin user also sees the link + $this->actingAs($this->admin); + $response = $this->get(route('dashboard')); + $response->assertSee('Tokens'); + }); + + it('properly displays the page title', function () { + $this->actingAs($this->user); + + $response = $this->get(route('tokens')); + + $response->assertSee('Authentication Tokens', false); + }); + + it('shows empty state when user has no tokens', function () { + $this->actingAs($this->user); + + $response = $this->get(route('tokens')); + + $response->assertSee('No tokens'); + $response->assertSee('authorized any applications'); + }); +}); \ No newline at end of file
- You can manage your profile and view your authentication tokens above. + You can manage your profile above and view your authentication tokens in the Tokens section.