Skip to content

[FE-01] Fix home page — redirect authenticated users to dashboard, unauthenticated to login #938

Description

@yusuftomilola

Overview

The home page at / currently renders only <h1>HomePage</h1>. There is no redirect logic. If a user navigates to the root URL, they see a blank page instead of being sent to the appropriate destination.

Context

  • File: frontend/app/page.tsx
  • The Zustand auth store at frontend/store/auth.store.ts exposes isAuthenticated and loadUser()
  • The middleware at frontend/middleware.ts already protects dashboard routes — the home page itself is unprotected
  • Pattern: check auth state on the client, redirect with useRouter from Next.js, or use a server-side redirect in page.tsx

Acceptance Criteria

  • On page load, call loadUser() to verify the current session
  • If the user is authenticated: redirect to /dashboard using router.replace('/dashboard')
  • If the user is not authenticated: redirect to /login
  • Show a loading spinner while the auth state is being determined (do not flash the raw page)
  • The redirect should be instant — no visible flash of the <h1>HomePage</h1> text

Metadata

Metadata

Assignees

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions