Add authentication, a public landing page, and guest data preview
Hand-rolled login/register/logout on Laravel's built-in Auth facade rather than Breeze/Jetstream, which scaffold Tailwind v3 config and would fight our existing Tailwind v4 CSS-first setup. Login/Register are Livewire components; logout is a plain POST route (auth-gated, CSRF-protected). Routing: "/" is now a public landing page describing the project; the sites list moved from "/" to "/sites" to make room for it. Data gating: App\Support\GuestPreview::paginate() forces page 1 and a 5-row page size for unauthenticated visitors on Sites, Discover, and a site's Pages/Backlinks tables, while total() still reflects the real match count — authenticated users get the existing full pagination unchanged. A shared guest-preview-notice component shows "N of M results, sign in to see all" and only renders when something is actually being hidden. Testing: pointed the test suite at a dedicated MySQL database (huginn_testing) instead of the default in-memory SQLite, since the existing fulltext index migration isn't SQLite-compatible — this app is MySQL-specific by now regardless. Added AuthFlowTest (register, login, wrong-password rejection, logout) and GuestPreviewTest (guest capped to a preview, authenticated sees everything), all passing. Also fixed a real bug the tests caught: request()->session() isn't reliably attached during Livewire's in-process test action calls; switched Login/Register to the session() helper, which resolves the session store directly and works in both contexts.
This commit is contained in:
@@ -0,0 +1,11 @@
|
||||
@props(['paginator'])
|
||||
|
||||
@if ($paginator->total() > $paginator->count())
|
||||
<p class="mt-4 rounded-md bg-blue-50 px-4 py-3 text-sm text-blue-800 dark:bg-blue-950 dark:text-blue-300">
|
||||
Showing a preview ({{ $paginator->count() }} of {{ number_format($paginator->total()) }} results).
|
||||
<a href="{{ route('login') }}" class="font-medium underline">Sign in</a>
|
||||
or
|
||||
<a href="{{ route('register') }}" class="font-medium underline">create a free account</a>
|
||||
to see everything.
|
||||
</p>
|
||||
@endif
|
||||
@@ -12,11 +12,23 @@
|
||||
<body class="min-h-screen bg-white text-neutral-900 antialiased dark:bg-neutral-950 dark:text-neutral-100">
|
||||
<header class="border-b border-neutral-200 dark:border-neutral-800">
|
||||
<div class="mx-auto flex max-w-5xl items-center gap-6 px-4 py-4">
|
||||
<a href="{{ route('sites.index') }}" class="text-lg font-semibold">Huginn</a>
|
||||
<nav class="flex gap-4 text-sm">
|
||||
<a href="{{ route('home') }}" class="text-lg font-semibold">Huginn</a>
|
||||
<nav class="flex flex-1 gap-4 text-sm">
|
||||
<a href="{{ route('sites.index') }}" class="text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100">Sites</a>
|
||||
<a href="{{ route('discover') }}" class="text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100">Discover</a>
|
||||
</nav>
|
||||
<nav class="flex items-center gap-4 text-sm">
|
||||
@auth
|
||||
<span class="text-neutral-500">{{ auth()->user()->name }}</span>
|
||||
<form method="POST" action="{{ route('logout') }}">
|
||||
@csrf
|
||||
<button type="submit" class="text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100">Log out</button>
|
||||
</form>
|
||||
@else
|
||||
<a href="{{ route('login') }}" class="text-neutral-600 hover:text-neutral-900 dark:text-neutral-400 dark:hover:text-neutral-100">Log in</a>
|
||||
<a href="{{ route('register') }}" class="rounded-md bg-neutral-900 px-3 py-1.5 font-medium text-white hover:bg-neutral-700 dark:bg-white dark:text-neutral-900 dark:hover:bg-neutral-200">Sign up</a>
|
||||
@endauth
|
||||
</nav>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user