diff --git a/web/app/(commonLayout)/layout.tsx b/web/app/(commonLayout)/layout.tsx index db7aa0fbe0ace6..ceeb1643157710 100644 --- a/web/app/(commonLayout)/layout.tsx +++ b/web/app/(commonLayout)/layout.tsx @@ -5,7 +5,6 @@ import { AppContextProvider } from '@/context/app-context' import GA, { GaType } from '@/app/components/base/ga' import HeaderWrapper from '@/app/components/header/HeaderWrapper' import Header from '@/app/components/header' -import SiteGuard from '@/app/components/site-guard' import { EventEmitterContextProvider } from '@/context/event-emitter' import { ProviderContextProvider } from '@/context/provider-context' import { ModalContextProvider } from '@/context/modal-context' @@ -13,7 +12,6 @@ import { ModalContextProvider } from '@/context/modal-context' const Layout = ({ children }: { children: ReactNode }) => { return ( <> - diff --git a/web/app/(shareLayout)/layout.tsx b/web/app/(shareLayout)/layout.tsx index 9c4632cd450dfa..3645a128aad27f 100644 --- a/web/app/(shareLayout)/layout.tsx +++ b/web/app/(shareLayout)/layout.tsx @@ -1,6 +1,7 @@ import React from 'react' import type { FC } from 'react' import GA, { GaType } from '@/app/components/base/ga' +import SiteGuard from '../components/site-guard' const Layout: FC<{ children: React.ReactNode @@ -8,6 +9,7 @@ const Layout: FC<{ return (
+ {children}
) diff --git a/web/app/components/site-guard/index.tsx b/web/app/components/site-guard/index.tsx index 6a393fad29825b..9d8ff7bedf1cc5 100644 --- a/web/app/components/site-guard/index.tsx +++ b/web/app/components/site-guard/index.tsx @@ -1,18 +1,18 @@ 'use client' -import React, { memo, useEffect, useState } from 'react'; +import React, { memo, useEffect, useState, useRef } from 'react'; import { usePathname } from 'next/navigation'; const SiteGuard = () => { const router = usePathname(); const [isAuthenticated, setIsAuthenticated] = useState(false); const [isCheckingAuth, setIsCheckingAuth] = useState(true); - const [promptShown, setPromptShown] = useState(false); + const promptShown = useRef(false); useEffect(() => { const checkAuth = async () => { - if (router.startsWith('/chat') && !promptShown) { + if (router.startsWith('/chat') && !promptShown.current) { const password = prompt('Enter password:'); - setPromptShown(true); + promptShown.current = true; if (password === 'cit2024') { setIsAuthenticated(true); @@ -27,7 +27,7 @@ const SiteGuard = () => { }; checkAuth(); - }, [router, promptShown]); + }, [router]); if (isCheckingAuth) { return
;