Added refresh checking logic for tokens.

This commit is contained in:
Patrick Fic
2020-01-02 09:13:55 -08:00
parent fa6a1b1eea
commit 8969108cc4
5 changed files with 63 additions and 24 deletions

View File

@@ -50,6 +50,8 @@ export default () => {
//add the bearer token to the headers.
localStorage.setItem("token", token);
const now = new Date();
window.sessionStorage.setItem(`lastTokenRefreshTime`, now);
apolloClient
.mutate({
@@ -61,23 +63,6 @@ export default () => {
console.log("User login upsert error.", error);
});
// apolloClient
// .query({
// query: QUERY_BODYSHOP,
// fetchPolicy: "network-only"
// })
// .then(r => {
// const bodyShopData = r.data.bodyshops[0];
// apolloClient.writeData({
// data: {
// bodyShopData: { ...bodyShopData, __typename: "bodyShopData" }
// }
// });
// })
// .catch(error => {
// console.log("Error getting bodyshop data.", error);
// });
apolloClient.writeData({
data: {
currentUser: {