From 97cb3b2e70752bbdb5b2364b0fad9363ae1ff4f4 Mon Sep 17 00:00:00 2001 From: Ebube Date: Tue, 17 Oct 2023 00:31:38 +0100 Subject: [PATCH] added comments for proper documentation --- middlewares/AuthRoute.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/middlewares/AuthRoute.js b/middlewares/AuthRoute.js index 9a458f7..5504723 100644 --- a/middlewares/AuthRoute.js +++ b/middlewares/AuthRoute.js @@ -2,16 +2,19 @@ import { useEffect } from "react"; import { useRouter } from "next/router"; +/** + * This is used to protect routes in a web application. + * It checks if the user is authenticated and redirects them to the sign-in page if they are not. + */ const AuthRoute = ({ children }) => { const router = useRouter(); useEffect(() => { - const isAuthenticated = false; + const isAuthenticated = true; // In a real application, this would be determined based on the user's authentication status. if (!isAuthenticated) { router.push("/authentication/sign-in/"); } - }, [router]); return <>{children};