API: Remove unused CSRF token logic
This commit is contained in:
parent
95a9163883
commit
1b36699021
1 changed files with 1 additions and 13 deletions
|
@ -2,7 +2,6 @@
|
||||||
|
|
||||||
import axios from 'axios';
|
import axios from 'axios';
|
||||||
import LinkHeader from 'http-link-header';
|
import LinkHeader from 'http-link-header';
|
||||||
import ready from './ready';
|
|
||||||
|
|
||||||
export const getLinks = response => {
|
export const getLinks = response => {
|
||||||
const value = response.headers.link;
|
const value = response.headers.link;
|
||||||
|
@ -14,17 +13,6 @@ export const getLinks = response => {
|
||||||
return LinkHeader.parse(value);
|
return LinkHeader.parse(value);
|
||||||
};
|
};
|
||||||
|
|
||||||
let csrfHeader = {};
|
|
||||||
|
|
||||||
function setCSRFHeader() {
|
|
||||||
const csrfToken = document.querySelector('meta[name=csrf-token]');
|
|
||||||
if (csrfToken) {
|
|
||||||
csrfHeader['X-CSRF-Token'] = csrfToken.content;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ready(setCSRFHeader);
|
|
||||||
|
|
||||||
const getToken = (getState, authType) =>
|
const getToken = (getState, authType) =>
|
||||||
getState().getIn(['auth', authType, 'access_token']);
|
getState().getIn(['auth', authType, 'access_token']);
|
||||||
|
|
||||||
|
@ -32,7 +20,7 @@ export default (getState, authType = 'user') => {
|
||||||
const accessToken = getToken(getState, authType);
|
const accessToken = getToken(getState, authType);
|
||||||
|
|
||||||
return axios.create({
|
return axios.create({
|
||||||
headers: Object.assign(csrfHeader, accessToken ? {
|
headers: Object.assign(accessToken ? {
|
||||||
'Authorization': `Bearer ${accessToken}`,
|
'Authorization': `Bearer ${accessToken}`,
|
||||||
} : {}),
|
} : {}),
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue