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',
error: '/signin',
},
debug: process.env.NODE_ENV === 'development',
debug: false,
};
const handler = NextAuth(authOptions);

View File

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

View File

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