Revert "Merge branch '629-cookie-auth' into 'develop'"

This reverts commit 8b47af8b81, reversing
changes made to c0055b3b20.
This commit is contained in:
Eliot Berriot 2019-03-15 15:52:30 +01:00
parent 666409dce0
commit b9f0c6aecd
No known key found for this signature in database
GPG key ID: DD6965E2476E5C27
18 changed files with 153 additions and 203 deletions

View file

@ -16,7 +16,6 @@ import GetTextPlugin from 'vue-gettext'
import { sync } from 'vuex-router-sync'
import locales from '@/locales'
import cookie from '@/utils/cookie'
import filters from '@/filters' // eslint-disable-line
import globals from '@/components/globals' // eslint-disable-line
@ -71,9 +70,8 @@ Vue.directive('title', function (el, binding) {
)
axios.interceptors.request.use(function (config) {
// Do something before request is sent
let csrfToken = cookie.get('csrftoken')
if (csrfToken) {
config.headers['X-CSRFToken'] = csrfToken
if (store.state.auth.token) {
config.headers['Authorization'] = store.getters['auth/header']
}
return config
}, function (error) {
@ -87,14 +85,9 @@ axios.interceptors.response.use(function (response) {
}, function (error) {
error.backendErrors = []
if (error.response.status === 401) {
if (error.response.config.skipLoginRedirect) {
return Promise.reject(error)
}
store.commit('auth/authenticated', false)
if (router.currentRoute.name !== 'login') {
logger.default.warn('Received 401 response from API, redirecting to login form', router.currentRoute.fullPath)
router.push({name: 'login', query: {next: router.currentRoute.fullPath}})
}
logger.default.warn('Received 401 response from API, redirecting to login form', router.currentRoute.fullPath)
router.push({name: 'login', query: {next: router.currentRoute.fullPath}})
}
if (error.response.status === 404) {
error.backendErrors.push('Resource not found')