HotFix for reload on expired token when you arrive on a queryless page

This commit is contained in:
Nikola Bjelo committed 2018-11-03 17:53:20 +01:00
1 parent 85d4dec89d
commit bfb8e84d84
2 files changed
+8 -1

No files matched your search

+1
View File
@@ -75,6 +75,7 @@
"classnames": "^2.2.6",
"graphql": "^14.0.2",
"graphql-tag": "^2.10.0",
"jwt-decode": "^2.2.0",
"mini-css-extract-plugin": "^0.4.4",
"npm": "^6.4.1",
"optimize-css-assets-webpack-plugin": "^5.0.1",
+7 -1
View File
@@ -1,5 +1,6 @@
import React, { Component } from 'react'
import PropTypes from 'prop-types'
import jwtDecode from 'jwt-decode'
import { withStyles } from '@material-ui/core/styles'
import AppBar from '@material-ui/core/AppBar'
@@ -81,7 +82,12 @@ class Header extends Component {
render () {
let { classes, auth } = this.props
if (window.localStorage.getItem('access_token')) {
if (jwtDecode(window.localStorage.getItem('access_token')).exp < new Date().getTime() / 1000) {
window.localStorage.clear()
window.location.reload()
}
}
let user = JSON.parse(this.state.user)
return (
<div className={classes.root}>