Neah version calendar fix 3 debuger ???? ?????????

This commit is contained in:
alma 2025-04-16 22:58:19 +02:00
parent 97a0bbe31d
commit a1e910e866
3 changed files with 11 additions and 7 deletions

View File

@ -136,7 +136,7 @@ export const authOptions: NextAuthOptions = {
signIn: '/signin', signIn: '/signin',
error: '/signin', error: '/signin',
}, },
debug: process.env.NODE_ENV === 'development', debug: false,
}; };
const handler = NextAuth(authOptions); const handler = NextAuth(authOptions);

View File

@ -3,10 +3,9 @@ import { Inter } from "next/font/google";
import "./globals.css"; import "./globals.css";
import { headers } from "next/headers"; import { headers } from "next/headers";
import { getServerSession } from "next-auth/next"; import { getServerSession } from "next-auth/next";
import { authOptions } from "@/app/api/auth/[...nextauth]/route"; import { authOptions } from "@/lib/auth";
import { Providers } from "@/components/providers"; import { Providers } from "@/components/providers";
import { LayoutWrapper } from "@/components/layout/layout-wrapper"; import { LayoutWrapper } from "@/components/layout/layout-wrapper";
import { SessionProvider } from "@/components/providers/session-provider";
import { Toaster } from "@/components/ui/toaster"; import { Toaster } from "@/components/ui/toaster";
const inter = Inter({ subsets: ["latin"] }); const inter = Inter({ subsets: ["latin"] });
@ -16,10 +15,12 @@ export default async function RootLayout({
}: { }: {
children: React.ReactNode; children: React.ReactNode;
}) { }) {
const session = await getServerSession(authOptions);
const headersList = headers(); const headersList = headers();
const pathname = headersList.get("x-pathname") || ""; const pathname = headersList.get("x-pathname") || "";
const isSignInPage = pathname === "/signin"; const isSignInPage = pathname === "/signin";
// Only check session if not on signin page
const session = !isSignInPage ? await getServerSession(authOptions) : null;
return ( return (
<html lang="fr"> <html lang="fr">
@ -32,6 +33,7 @@ export default async function RootLayout({
{children} {children}
</LayoutWrapper> </LayoutWrapper>
</Providers> </Providers>
<Toaster />
</body> </body>
</html> </html>
); );

View File

@ -2,18 +2,20 @@
import { useSession } from "next-auth/react"; import { useSession } from "next-auth/react";
import { usePathname, useRouter } from "next/navigation"; import { usePathname, useRouter } from "next/navigation";
import { useEffect } from "react"; import { useEffect, useState } from "react";
export function AuthCheck({ children }: { children: React.ReactNode }) { export function AuthCheck({ children }: { children: React.ReactNode }) {
const { data: session, status } = useSession(); const { data: session, status } = useSession();
const pathname = usePathname(); const pathname = usePathname();
const router = useRouter(); const router = useRouter();
const [isRedirecting, setIsRedirecting] = useState(false);
useEffect(() => { useEffect(() => {
if (status === "unauthenticated" && pathname !== "/signin") { if (status === "unauthenticated" && pathname !== "/signin" && !isRedirecting) {
setIsRedirecting(true);
router.push("/signin"); router.push("/signin");
} }
}, [status, router, pathname]); }, [status, router, pathname, isRedirecting]);
if (status === "loading") { if (status === "loading") {
return <div>Chargement...</div>; return <div>Chargement...</div>;