From b7373a4fb3591e70599a4ad17f766f0ad1a7272a Mon Sep 17 00:00:00 2001 From: Gemma Date: Wed, 27 Dec 2023 13:07:45 +0100 Subject: [PATCH] log in fixed --- frontend/src/components/NavBar/Navbar.js | 20 +++++--- frontend/src/components/SignIn/LoggedIn.js | 15 ++++++ frontend/src/components/SignIn/SignInForm.js | 4 +- .../src/components/context/AuthContext.js | 4 +- frontend/src/index.js | 48 +++++++++---------- 5 files changed, 57 insertions(+), 34 deletions(-) diff --git a/frontend/src/components/NavBar/Navbar.js b/frontend/src/components/NavBar/Navbar.js index bc5a999..29f77c6 100644 --- a/frontend/src/components/NavBar/Navbar.js +++ b/frontend/src/components/NavBar/Navbar.js @@ -5,6 +5,8 @@ import { useContext } from 'react' import { useAuth } from 'oidc-react' import OutsideClickHandler from 'react-outside-click-handler' import './Navbar.css' +import { useNavigate } from 'react-router-dom' +import LoggedIn from '../SignIn/LoggedIn' function Navbar () { const [selected, setIsSelected] = useState('') @@ -18,7 +20,9 @@ function Navbar () { getStoredToken, userNameToShare } = useContext(AuthContext) + const auth = useAuth() + const navigate = useNavigate() useEffect(() => { console.log(auth) @@ -27,10 +31,13 @@ function Navbar () { let isAuthenticated = false if (token === null) { isAuthenticated = auth.userData?.id_token ? true : false + console.log(isAuthenticated) + console.log(auth.userData) } else { isAuthenticated = true + console.log(isAuthenticated) } - + if (isAuthenticated || isLoggedIn === true) { setIsLoggedIn(true) } else { @@ -46,7 +53,7 @@ function Navbar () { setOpenMenu(!openMenu) } - const handleClik = () => { + const handleClick = () => { setIsLoggedIn(false) auth.signOut() logOutUser() @@ -55,6 +62,7 @@ function Navbar () { return (
+
-