Skip to content

[FE-44] Set up protected route middleware #915

Description

@mftee

Overview

Once auth state exists (FE-43), pages like /dashboard or /documents need to redirect unauthenticated users to /login rather than rendering and failing on missing data.

Tech

Next.js middleware.ts at the app root, checking for a session cookie/token.

Acceptance Criteria

  • Create middleware.ts matching protected route prefixes (/dashboard, /documents, /profile, /settings, /admin, /disputes)
  • Unauthenticated requests to a protected route redirect to /login?redirect=<original-path>
  • After successful login, the user is returned to the original requested path
  • /admin/* routes additionally verify the user's role and redirect non-admins to /dashboard

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions