From a57a1d7ba591e0bceee8b5337a9683dc8a9dec94 Mon Sep 17 00:00:00 2001 From: xdemocle Date: Fri, 17 Dec 2021 17:20:40 +0100 Subject: [PATCH] [FAIR-85] refactoring authentication feature --- components/Topbar/index.tsx | 9 +++++---- pages/index.tsx | 15 ++++++++------- 2 files changed, 13 insertions(+), 11 deletions(-) diff --git a/components/Topbar/index.tsx b/components/Topbar/index.tsx index 764a0d3..0f205a4 100644 --- a/components/Topbar/index.tsx +++ b/components/Topbar/index.tsx @@ -8,7 +8,7 @@ import DappIcon from 'assets/icons/dapp.svg'; import useUser from 'hooks/useUser'; const Topbar = () => { - const { user, logout } = useUser(); + const { user, isAuthenticated } = useUser(); return (
{
- FairOS (Server) + {isAuthenticated && FairOS (Server)}
- + {isAuthenticated && } - {!!user && ( + + {isAuthenticated && ( <> Activity diff --git a/pages/index.tsx b/pages/index.tsx index 2e3dc0f..16c41fe 100644 --- a/pages/index.tsx +++ b/pages/index.tsx @@ -5,19 +5,20 @@ import Router from 'next/router'; import { useEffect } from 'react'; const Home: NextPage = () => { - const { user } = useUser(); + const { isAuthenticated } = useUser(); useEffect(() => { - if (!user) { + if (!isAuthenticated) { Router.push('/login'); } - }, [user]); + }, [isAuthenticated]); return ( - -

Fairdrive

- {!user &&

user loggeout

} -
+ isAuthenticated && ( + +

Fairdrive

+
+ ) ); };