--- phase: 01-foundation plan: 02 subsystem: auth tags: [next-auth, next.js, tailwind, server-actions, server-components, client-components] # Dependency graph requires: - phase: 01-foundation/01-01 provides: "src/lib/auth.ts with signIn/signOut/auth exports; middleware.ts protecting /agent/*" provides: - src/app/agent/login/page.tsx — branded login page with email/password form, error banner, signed-out confirmation - src/app/agent/login/PasswordField.tsx — client component for password show/hide toggle - src/app/agent/layout.tsx — agent portal layout with defense-in-depth auth() check and header - src/app/agent/dashboard/page.tsx — protected dashboard stub showing agent email - src/components/ui/LogoutButton.tsx — form-action logout triggering signOut({ redirectTo: "/agent/login?signed_out=1" }) - public/red.jpg — agent brand photo served as static asset affects: - 01-03 - all subsequent phases using /agent/* routes or LogoutButton # Tech tracking tech-stack: added: [] patterns: - Server action inside page file: loginAction with try/catch — re-throw non-AuthError (allows NEXT_REDIRECT to bubble) - Client sub-component in same route folder: PasswordField.tsx co-located with login page - Defense-in-depth auth: middleware (primary) + layout auth() + page auth() (belt-and-suspenders) - Form action pattern for logout: avoids NEXT_REDIRECT catch issues by using