From df8ca7a3e0b050e3faf0bc3e6dcd8ef7670b1f61 Mon Sep 17 00:00:00 2001 From: Nikola Bjelo Date: Tue, 23 Oct 2018 09:30:42 +0200 Subject: [PATCH] Minimal "if expired, logout" system That way I don't loose time at looking for token refreshing if somebody already knows how to do it with auth0 --- client/src/graphql/apollo.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/client/src/graphql/apollo.js b/client/src/graphql/apollo.js index b036dd862..876497ccb 100644 --- a/client/src/graphql/apollo.js +++ b/client/src/graphql/apollo.js @@ -19,7 +19,10 @@ const authRetryLink = onError( if (graphQLErrors) { // User access token has expired // console.log('authLink: ', graphQLErrors) // check for error message to intercept and resend with Auth0 access token - if (graphQLErrors[0].message === 'Not logged in') { + if (graphQLErrors[0].message === 'Context creation failed: jwt expired') { + window.localStorage.clear() + location.reload() + } else if (graphQLErrors[0].message === 'Not logged in') { // We assume we have auth0 access token needed to run the async request // Let's refresh token through async request return new Observable(observer => {