Dashboard Routes Restructuring Plan
Dashboard Routes Restructuring Plan
Critical Security Issue π¨
Current Problem: Publication dashboard routes at /[publication]/dashboard are NOT protected by authentication middleware, allowing unauthorized access to publication settings!
Root Cause
In middleware.ts:70-82, the authentication check is:
if (path.startsWith("/dashboard") || path.startsWith("/login")) {
const session = await getToken({ req, secret: env.NEXTAUTH_SECRET });
if (!session && path.startsWith("/dashboard")) {
// redirect to login
}
}
This only protects routes starting with /dashboard, but publication dashboards are at:
/[publication]/dashboard(e.g.,/my-publication/dashboard)
These paths start with the publication slug, NOT /dashboard, so they bypass authentication entirely!
Current Route Structure Analysis
Authenticated Dashboard Routes (Protected)
/dashboard β User overview (sites & publications)
/dashboard/settings β User account settings
/dashboard/new β Create new site
/dashboard/admin β Admin panel
/dashboard/publications/new β Create new publication
/dashboard/site/[id]/settings β Site settings β οΈ singular "site"
/dashboard/site/[id]/analytics β Site analytics
/dashboard/site/[id]/settings/appearance β Site appearance
Publication Routes (NOT Protected! β οΈ)
/[publication]/dashboard β Publication management (VULNERABLE!)
ββ Tabs: posts, settings
Public Routes (No Auth Required)
/ β Landing page
/[publication] β Public publication view
/[publication]/[post]/[[...slug]] β Public post view
Issues Identified
- π Security Vulnerability: Publication dashboards bypass middleware authentication
- π Inconsistent Structure: Management routes split between
/dashboard/*and/[publication]/dashboard - π·οΈ Inconsistent Naming:
/dashboard/site/[id]/*(singular and using id)/[publication]/dashboard(using slug and/dashboardsuffix instead of prefix)/dashboard/publications/new(plural)
- π€ Confusing UX: Hard to understand where to find things
- π§ Hard to Maintain: Scattered dashboard logic across different route segments
Proposed Solution
New Consolidated Dashboard Structure
All authenticated admin/management routes under /dashboard with consistent plural naming:
PUBLIC ROUTES (No authentication required)
βββ / β Landing page
βββ /pricing β Pricing page
βββ /solutions β Solutions page
βββ /[publication] β Public publication homepage
βββ /[publication]/[post]/[[...slug]] β Public post view
AUTHENTICATED ROUTES (All under /dashboard)
βββ /dashboard β Publications list (Rewrite to /dashboard/publications)
βββ /dashboard/settings β User account settings
βββ /dashboard/admin β Admin panel
β
βββ /dashboard/sites/new β Create new site
βββ /dashboard/sites/[id]/settings β Site settings
βββ /dashboard/sites/[id]/analytics β Site analytics
βββ /dashboard/sites/[id]/settings/appearance β Site appearance
β
βββ /dashboard/publications β Publications list (redirect to /dashboard)
βββ /dashboard/publications/new β Create new publication
βββ /dashboard/publications/[id] β Publication management β
MOVED HERE
βββ ?tab=posts β Manage posts
βββ ?tab=settings β Publication settings