Fixed broken login redirection when 401
This commit is contained in:
parent
e0820dfa1c
commit
45e8421061
|
@ -5,6 +5,9 @@ Changelog
|
|||
0.3.5 (Unreleased)
|
||||
------------------
|
||||
|
||||
- Front: added some unittests for the store (#55)
|
||||
- Front: fixed broken login redirection when 401
|
||||
|
||||
|
||||
0.3.5 (2018-01-07)
|
||||
------------------
|
||||
|
|
|
@ -37,13 +37,13 @@ axios.interceptors.request.use(function (config) {
|
|||
|
||||
// Add a response interceptor
|
||||
axios.interceptors.response.use(function (response) {
|
||||
if (response.status === 401) {
|
||||
return response
|
||||
}, function (error) {
|
||||
if (error.response.status === 401) {
|
||||
store.commit('auth/authenticated', false)
|
||||
logger.default.warn('Received 401 response from API, redirecting to login form')
|
||||
router.push({name: 'login', query: {next: router.currentRoute.fullPath}})
|
||||
}
|
||||
return response
|
||||
}, function (error) {
|
||||
// Do something with response error
|
||||
return Promise.reject(error)
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue