Shell
Sign-In Modal Implementation Plan
Goal
Replace hard redirect to /sign-in with a modal overlay that keeps users on the page they're viewing. Background blurs/darkens, clicking outside dismisses.
Current State
- Middleware does hard redirect to
/sign-infor protected routes - Users feel "trapped" in the login flow
- Loses context of where they were
Proposed Architecture
Approach: Client-Side Auth Gating
Instead of server-side redirect, let the page load and show a modal overlay if not authenticated.
Key insight: This mirrors the existing PurchaseGate pattern - which already shows a modal instead of redirecting when user hasn't purchased.
Components to Create
/components/auth/SignInModal.tsx- Reuses sign-in form logic from
/app/(auth)/sign-in/page.tsx - Modal overlay with blur backdrop (pattern from
LeadMagnetFunnel.tsx) - Google OAuth + Magic Link + Password options
onCloseprop to dismissonSuccessprop to refresh content after auth
- Reuses sign-in form logic from
/components/auth/AuthGate.tsx- Wrapper component for protected content
- Checks auth state client-side
- If not authenticated: show
SignInModalover blurred content - If authenticated: render children normally
Middleware Changes
Modify /middleware.ts to not redirect for course module pages - let client-side AuthGate handle protection.
Page Updates
Wrap protected module pages in AuthGate:
// /app/courses/claude-for-knowledge-workers/module-1/page.tsx
export default function Module1Page() {
return (
<AuthGate moduleName="Module 1">
<PurchaseGate productId="claude-for-knowledge-workers">
{/* Module content */}
</PurchaseGate>
</AuthGate>
)
}
Implementation Steps
- Create SignInModal - Extract sign-in form, add modal wrapper with blur backdrop
- Create AuthGate - Wrapper that checks auth and shows modal or children
- Update middleware - Remove course module redirect logic
- Wrap protected pages - Add AuthGate to module-1 through module-5
Files to Modify
| File | Change |
|---|---|
/components/auth/SignInModal.tsx |
CREATE |
/components/auth/AuthGate.tsx |
CREATE |
/middleware.ts |
MODIFY |
/app/courses/claude-for-knowledge-workers/module-1/page.tsx |
MODIFY |
/app/courses/claude-for-knowledge-workers/module-2/page.tsx |
MODIFY |
/app/courses/claude-for-knowledge-workers/module-3/page.tsx |
MODIFY |
/app/courses/claude-for-knowledge-workers/module-4/page.tsx |
MODIFY |
/app/courses/claude-for-knowledge-workers/module-5/page.tsx |
MODIFY |
UX Flow (After Implementation)
- User clicks on Module 1 link
- Page loads with content visible but blurred behind modal
- SignInModal appears centered with dark backdrop
- User can:
- Sign in → modal closes, content reveals
- Click outside → modal closes, navigate back to course landing (user choice)
- ESC key → same as click outside
Design Details
Modal styling (from LeadMagnetFunnel pattern):
// Backdrop - click to dismiss and navigate back
<motion.div
className="fixed inset-0 z-50 flex items-center justify-center p-4 bg-black/60 backdrop-blur-sm"
onClick={() => router.push('/courses/claude-for-knowledge-workers')}
>
// Modal - prevent click bubbling
<motion.div
className="bg-[var(--bg-primary)] rounded-2xl shadow-2xl max-w-md w-full"
onClick={e => e.stopPropagation()}
>