From d203a26bdec665655a89fff33fe894fbe0dfe91c Mon Sep 17 00:00:00 2001 From: Dawid Tarasiuk Date: Wed, 15 Jul 2020 16:09:12 +0200 Subject: [PATCH] Update auth provider --- src/auth/AuthProvider.tsx | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/auth/AuthProvider.tsx b/src/auth/AuthProvider.tsx index e9f1cb38d..ba65ea14f 100644 --- a/src/auth/AuthProvider.tsx +++ b/src/auth/AuthProvider.tsx @@ -65,15 +65,6 @@ const AuthProvider: React.FC = ({ children }) => { } }; - useEffect(() => { - const token = getAuthToken(); - if (!!token && !userContext) { - verifyToken(token); - } else { - loginWithCredentialsManagementAPI(login); - } - }, []); - useEffect(() => { if (tokenAuthOpts.error || tokenVerifyOpts.error) { logout(); @@ -98,6 +89,15 @@ const AuthProvider: React.FC = ({ children }) => { } }, [tokenAuthOpts, tokenVerifyOpts]); + useEffect(() => { + const token = getAuthToken(); + if (!!token && !userContext) { + verifyToken(token); + } else { + loginWithCredentialsManagementAPI(login); + } + }, []); + const login = async (email: string, password: string) => { tokenAuth({ variables: { email, password } }).then(result => { if (result && !result.data.tokenCreate.errors.length) {