diff --git a/frontend/src/components/Footer/Footer.js b/frontend/src/components/Footer/Footer.js index 36ea499..22f1803 100644 --- a/frontend/src/components/Footer/Footer.js +++ b/frontend/src/components/Footer/Footer.js @@ -1,7 +1,45 @@ import './Footer.css' import { NavLink } from 'react-router-dom' +import { useEffect } from 'react' +import { AuthContext } from '../context/AuthContext' +import { useContext } from 'react' +import { useAuth } from 'oidc-react' function Footer (props) { + const { + isLoggedIn, + setIsLoggedIn, + logOutUser, + authenticateUser, + getStoredToken, + userNameToShare, + setUserNameToShare + } = useContext(AuthContext) + + const handleClick = () => { + setIsLoggedIn(false) + auth.signOut() + logOutUser() + } + const auth = useAuth() + + useEffect(() => { + authenticateUser() + let token = getStoredToken() + let isAuthenticated = false + if (token === null) { + isAuthenticated = auth.userData?.id_token ? true : false + } else { + isAuthenticated = true + } + + if (isAuthenticated || isLoggedIn === true) { + setIsLoggedIn(true) + } else { + setIsLoggedIn(false) + } + }, []) + return (