Neah version calendar fix 3 debuger ???? ?????????
This commit is contained in:
parent
97a0bbe31d
commit
a1e910e866
@ -136,7 +136,7 @@ export const authOptions: NextAuthOptions = {
|
||||
signIn: '/signin',
|
||||
error: '/signin',
|
||||
},
|
||||
debug: process.env.NODE_ENV === 'development',
|
||||
debug: false,
|
||||
};
|
||||
|
||||
const handler = NextAuth(authOptions);
|
||||
|
||||
@ -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,10 +15,12 @@ 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">
|
||||
@ -32,6 +33,7 @@ export default async function RootLayout({
|
||||
{children}
|
||||
</LayoutWrapper>
|
||||
</Providers>
|
||||
<Toaster />
|
||||
</body>
|
||||
</html>
|
||||
);
|
||||
|
||||
@ -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>;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user