From 9377b5ca7b18f5b9c232d1b4d51ed9c70bb67bfd Mon Sep 17 00:00:00 2001 From: "Haelwenn (lanodan) Monnier" Date: Fri, 1 Feb 2019 16:32:07 +0100 Subject: [PATCH] {mastodon,flavours/glitch/util}/api.js: Remove csrf-token query --- app/javascript/flavours/glitch/util/api.js | 16 ++-------------- app/javascript/mastodon/api.js | 16 ++-------------- 2 files changed, 4 insertions(+), 28 deletions(-) diff --git a/app/javascript/flavours/glitch/util/api.js b/app/javascript/flavours/glitch/util/api.js index c59a24518..65aa61ba7 100644 --- a/app/javascript/flavours/glitch/util/api.js +++ b/app/javascript/flavours/glitch/util/api.js @@ -1,5 +1,4 @@ import axios from 'axios'; -import ready from './ready'; import LinkHeader from 'http-link-header'; export const getLinks = response => { @@ -12,21 +11,10 @@ export const getLinks = response => { 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); - export default getState => axios.create({ - headers: Object.assign(csrfHeader, getState ? { + headers: getState ? { 'Authorization': `Bearer ${getState().getIn(['meta', 'access_token'], '')}`, - } : {}), + } : {}, transformResponse: [function (data) { try { diff --git a/app/javascript/mastodon/api.js b/app/javascript/mastodon/api.js index 98d59de43..65aa61ba7 100644 --- a/app/javascript/mastodon/api.js +++ b/app/javascript/mastodon/api.js @@ -1,6 +1,5 @@ import axios from 'axios'; import LinkHeader from 'http-link-header'; -import ready from './ready'; export const getLinks = response => { const value = response.headers.link; @@ -12,21 +11,10 @@ export const getLinks = response => { 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); - export default getState => axios.create({ - headers: Object.assign(csrfHeader, getState ? { + headers: getState ? { 'Authorization': `Bearer ${getState().getIn(['meta', 'access_token'], '')}`, - } : {}), + } : {}, transformResponse: [function (data) { try {