mirror of
https://github.com/soconnor0919/hristudio.git
synced 2025-12-11 06:34:44 -05:00
- Remove outdated root-level documentation files - Delete IMPLEMENTATION_STATUS.md, WORK_IN_PROGRESS.md, UI_IMPROVEMENTS_SUMMARY.md, CLAUDE.md - Reorganize documentation into docs/ folder - Move UNIFIED_EDITOR_EXPERIENCES.md → docs/unified-editor-experiences.md - Move DATATABLE_MIGRATION_PROGRESS.md → docs/datatable-migration-progress.md - Move SEED_SCRIPT_README.md → docs/seed-script-readme.md - Create comprehensive new documentation - Add docs/implementation-status.md with production readiness assessment - Add docs/work-in-progress.md with active development tracking - Add docs/development-achievements.md consolidating all major accomplishments - Update documentation hub - Enhance docs/README.md with complete 13-document structure - Organize into logical categories: Core, Status, Achievements - Provide clear navigation and purpose for each document Features: - 73% code reduction achievement through unified editor experiences - Complete DataTable migration with enterprise features - Comprehensive seed database with realistic research scenarios - Production-ready status with 100% backend, 95% frontend completion - Clean documentation architecture supporting future development Breaking Changes: None - documentation restructuring only Migration: Documentation moved to docs/ folder, no code changes required
56 lines
1.7 KiB
TypeScript
56 lines
1.7 KiB
TypeScript
import type { Session } from "next-auth";
|
|
import type { NextRequest } from "next/server";
|
|
import { NextResponse } from "next/server";
|
|
import { auth } from "./src/server/auth";
|
|
|
|
export default auth((req: NextRequest & { auth: Session | null }) => {
|
|
const { nextUrl } = req;
|
|
const isLoggedIn = !!req.auth;
|
|
|
|
// Define route patterns
|
|
const isApiAuthRoute = nextUrl.pathname.startsWith("/api/auth");
|
|
const isPublicRoute = ["/", "/auth/signin", "/auth/signup"].includes(
|
|
nextUrl.pathname,
|
|
);
|
|
const isAuthRoute = nextUrl.pathname.startsWith("/auth");
|
|
|
|
// Allow API auth routes to pass through
|
|
if (isApiAuthRoute) {
|
|
return NextResponse.next();
|
|
}
|
|
|
|
// If user is on auth pages and already logged in, redirect to dashboard
|
|
if (isAuthRoute && isLoggedIn) {
|
|
return NextResponse.redirect(new URL("/", nextUrl));
|
|
}
|
|
|
|
// If user is not logged in and trying to access protected routes
|
|
if (!isLoggedIn && !isPublicRoute && !isAuthRoute) {
|
|
let callbackUrl = nextUrl.pathname;
|
|
if (nextUrl.search) {
|
|
callbackUrl += nextUrl.search;
|
|
}
|
|
|
|
const encodedCallbackUrl = encodeURIComponent(callbackUrl);
|
|
return NextResponse.redirect(
|
|
new URL(`/auth/signin?callbackUrl=${encodedCallbackUrl}`, nextUrl),
|
|
);
|
|
}
|
|
|
|
return NextResponse.next();
|
|
});
|
|
|
|
// Configure which routes the middleware should run on
|
|
export const config = {
|
|
matcher: [
|
|
/*
|
|
* Match all request paths except for the ones starting with:
|
|
* - _next/static (static files)
|
|
* - _next/image (image optimization files)
|
|
* - favicon.ico (favicon file)
|
|
* - public files (images, etc.)
|
|
*/
|
|
"/((?!_next/static|_next/image|favicon.ico|.*\\.(?:svg|png|jpg|jpeg|gif|webp)$).*)",
|
|
],
|
|
};
|