init: lab project bootstrapped from isletmem-kovakcrm
- CRM domain modules removed (customers, services, software, calendar, tasks, invoices, leads, finance, etc.)
- DLS branding: package name=lab, logo wordmark, sidebar nav, header CTA
- Tenant layer extended with kind dimension (lab|clinic) + requireTenantKind helper
- Schema rewritten for DLS domain: jobs, job_files, job_status_history, prosthetics, connections, finance_entries, notifications
- Onboarding form: clinic/lab account-type selection + auto-generated memberNumber
- Placeholder routes for jobs/{inbound,outbound,new}, products, finance, connections
- PDF spec + spec.md under belgeler/
- db: lab database + 13 collections + indexes + storage bucket (job-files) provisioned via Appwrite MCP
Ref: belgeler/dls-ui-tasarim.pdf
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
import { NextResponse } from "next/server";
|
||||
import type { NextRequest } from "next/server";
|
||||
|
||||
const AUTH_COOKIE = "lab-session";
|
||||
|
||||
const PUBLIC_AUTH_PATHS = [
|
||||
"/sign-in",
|
||||
"/sign-in-2",
|
||||
"/sign-in-3",
|
||||
"/sign-up",
|
||||
"/sign-up-2",
|
||||
"/sign-up-3",
|
||||
"/forgot-password",
|
||||
"/forgot-password-2",
|
||||
"/forgot-password-3",
|
||||
"/reset-password",
|
||||
];
|
||||
|
||||
const PROTECTED_PREFIXES = ["/dashboard", "/onboarding", "/settings"];
|
||||
|
||||
export function middleware(request: NextRequest) {
|
||||
const { pathname } = request.nextUrl;
|
||||
const session = request.cookies.get(AUTH_COOKIE)?.value;
|
||||
|
||||
// Legacy redirects
|
||||
if (pathname === "/login") {
|
||||
return NextResponse.redirect(new URL("/sign-in", request.url));
|
||||
}
|
||||
if (pathname === "/register") {
|
||||
return NextResponse.redirect(new URL("/sign-up", request.url));
|
||||
}
|
||||
|
||||
const isAuthPath = PUBLIC_AUTH_PATHS.some(
|
||||
(p) => pathname === p || pathname.startsWith(`${p}/`),
|
||||
);
|
||||
const isProtected = PROTECTED_PREFIXES.some(
|
||||
(p) => pathname === p || pathname.startsWith(`${p}/`),
|
||||
);
|
||||
|
||||
if (isProtected && !session) {
|
||||
const url = new URL("/sign-in", request.url);
|
||||
url.searchParams.set("redirect", pathname);
|
||||
return NextResponse.redirect(url);
|
||||
}
|
||||
|
||||
if (isAuthPath && session) {
|
||||
return NextResponse.redirect(new URL("/dashboard", request.url));
|
||||
}
|
||||
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
export const config = {
|
||||
matcher: ["/((?!api|_next/static|_next/image|favicon.ico).*)"],
|
||||
};
|
||||
Reference in New Issue
Block a user