Skip to content

Commit c507dfa

Browse files
committed
add Invalid token handler
1 parent f6d2e89 commit c507dfa

1 file changed

Lines changed: 15 additions & 9 deletions

File tree

browser/main/index.js

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,13 +41,19 @@ ReactDOM.render((
4141
loadingCover.parentNode.removeChild(loadingCover)
4242

4343
// Refresh user information
44-
fetchCurrentUser()
45-
.then(function (res) {
46-
let user = res.body
47-
store.dispatch(updateUser(user))
48-
})
49-
.catch(function (err) {
50-
console.error(err.message)
51-
console.log('Fetch failed')
52-
})
44+
if (auth.user() != null) {
45+
fetchCurrentUser()
46+
.then(function (res) {
47+
let user = res.body
48+
store.dispatch(updateUser(user))
49+
})
50+
.catch(function (err) {
51+
if (err.status === 401) {
52+
auth.clear()
53+
if (window != null) window.location.reload()
54+
}
55+
console.error(err.message)
56+
console.log('Fetch failed')
57+
})
58+
}
5359
})

0 commit comments

Comments
 (0)