Skip to content

[auth] add protected admin layout with nav and logout #79

Description

@WilliamTayNZ

Important: When you begin this ticket, create a new branch from feat/admin-auth and not main. When you open a PR, open it into feat/admin-auth and not main.

Description

Replace the bare wrapper div in src/app/admin/layout.tsx with a functional admin shell that displays the current user, provides navigation, and allows logout.

Requirements

  • Call getSession() in the layout to identify the current admin
  • Display the admin's name (will require looking up the admin by ID from the session — add a call to findAdminById from adminRepository)
  • Render nav links: "Members" linking to /admin/members (blog/emails can be added later on)
  • Add a logout button implemented as a <form> with a server action that calls logoutAdmin() then redirects to /admin/login
  • Must work without client JavaScript - the logout must be a real <form> submission, not an onClick handler

Acceptance Criteria

  • Admin layout shows the logged-in admin's name
  • Nav contains a working link to /admin/members
  • Logout button ends the session and redirects to /admin/login
  • Logout works with JavaScript disabled
  • Layout only renders the admin shell for authenticated routes (login page should not show the nav/logout)

Notes

The login page sits under (public)/login/ route group, so it uses a different layout chain and won't inherit this nav - that's already handled by the folder structure.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions