diff --git a/.gitignore b/.gitignore index d8d6005..7861025 100644 --- a/.gitignore +++ b/.gitignore @@ -13,4 +13,7 @@ node_modules # Scripts de développement copy.sh -start.sh \ No newline at end of file +start.sh + +# Playbook développement +ansible/playbooks/dev \ No newline at end of file diff --git a/front/app/layout.tsx b/front/app/layout.tsx index 14224b8..a3c5417 100644 --- a/front/app/layout.tsx +++ b/front/app/layout.tsx @@ -6,9 +6,34 @@ import "./globals.css"; import { MainNav } from "@/components/main-nav"; import Link from "next/link"; import { SessionProvider } from "next-auth/react"; +import { useSession } from "next-auth/react"; +import { usePathname, useRouter } from "next/navigation"; +import { useEffect } from "react"; const inter = Inter({ subsets: ["latin"] }); +function AuthCheck({ children }: { children: React.ReactNode }) { + const { data: session, status } = useSession(); + const pathname = usePathname(); + const router = useRouter(); + + useEffect(() => { + if (status === "unauthenticated" && pathname !== "/signin") { + router.push("/signin"); + } + }, [status, router, pathname]); + + if (status === "loading") { + return