database wf 12
This commit is contained in:
parent
68b01bbfb6
commit
d62f02b1df
19
app/page.tsx
19
app/page.tsx
@ -6,8 +6,27 @@ import { News } from "@/components/news";
|
||||
import { Duties } from "@/components/flow";
|
||||
import { Email } from "@/components/email";
|
||||
import { Parole } from "@/components/parole";
|
||||
import { useSession } from "next-auth/react";
|
||||
import { useEffect, useState } from "react";
|
||||
|
||||
export default function Home() {
|
||||
const { data: session, status } = useSession();
|
||||
const [isLoading, setIsLoading] = useState(true);
|
||||
|
||||
useEffect(() => {
|
||||
if (status !== "loading") {
|
||||
setIsLoading(false);
|
||||
}
|
||||
}, [status]);
|
||||
|
||||
if (isLoading) {
|
||||
return (
|
||||
<main className="h-screen flex items-center justify-center">
|
||||
<div className="animate-spin rounded-full h-32 w-32 border-t-2 border-b-2 border-gray-900"></div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<main className="h-screen overflow-auto">
|
||||
<div className="container mx-auto p-4 mt-12">
|
||||
|
||||
@ -3,18 +3,6 @@ import { NextResponse } from "next/server";
|
||||
|
||||
export default withAuth(
|
||||
function middleware(req) {
|
||||
// Allow access to public paths
|
||||
if (
|
||||
req.nextUrl.pathname === "/" ||
|
||||
req.nextUrl.pathname === "/signin" ||
|
||||
req.nextUrl.pathname.startsWith("/_next") ||
|
||||
req.nextUrl.pathname.startsWith("/api/auth") ||
|
||||
req.nextUrl.pathname.startsWith("/public")
|
||||
) {
|
||||
return NextResponse.next();
|
||||
}
|
||||
|
||||
// For all other routes, check authentication
|
||||
return NextResponse.next();
|
||||
},
|
||||
{
|
||||
@ -31,6 +19,20 @@ export default withAuth(
|
||||
return true;
|
||||
}
|
||||
|
||||
// For API routes, check if the request is for mail or other protected endpoints
|
||||
if (req.nextUrl.pathname.startsWith('/api/')) {
|
||||
// Allow access to public API endpoints
|
||||
if (
|
||||
req.nextUrl.pathname.startsWith('/api/auth') ||
|
||||
req.nextUrl.pathname.startsWith('/api/news')
|
||||
) {
|
||||
return true;
|
||||
}
|
||||
|
||||
// Require authentication for protected API endpoints
|
||||
return !!token;
|
||||
}
|
||||
|
||||
// For all other routes, require a valid token
|
||||
return !!token;
|
||||
},
|
||||
|
||||
Loading…
Reference in New Issue
Block a user