From c5c576adddaec082b2228e9b0beb29c783a04d51 Mon Sep 17 00:00:00 2001 From: Christoph Wurst Date: Mon, 8 Oct 2018 15:26:54 +0200 Subject: [PATCH] Replace hand-crafted request token logic by nextcloud-axios lib Signed-off-by: Christoph Wurst --- settings/package-lock.json | 49 +++++++++++++++----------------------- settings/package.json | 2 +- settings/src/store/api.js | 15 +++++------- settings/src/store/apps.js | 1 - 4 files changed, 26 insertions(+), 41 deletions(-) diff --git a/settings/package-lock.json b/settings/package-lock.json index 7e41cbda47..50464f1979 100644 --- a/settings/package-lock.json +++ b/settings/package-lock.json @@ -3292,8 +3292,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -3314,14 +3313,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -3336,20 +3333,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -3466,8 +3460,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -3479,7 +3472,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -3494,7 +3486,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -3502,14 +3493,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.2.4", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.1", "yallist": "^3.0.0" @@ -3528,7 +3517,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -3609,8 +3597,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -3622,7 +3609,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -3708,8 +3694,7 @@ "safe-buffer": { "version": "5.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -3745,7 +3730,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -3765,7 +3749,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -3809,14 +3792,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -5078,6 +5059,14 @@ "integrity": "sha512-vdqTKI9GBIYcAEbFAcpKPErKINfPF5zIuz3/niBfq8WUZjpT2tytLlFVrBgWdOtqI4uaA/Rb6No0hux39XXDuw==", "dev": true }, + "nextcloud-axios": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/nextcloud-axios/-/nextcloud-axios-0.1.2.tgz", + "integrity": "sha512-iGmsgetYead0678dpExmYaN4odpiKjKxtPpzuk3TyB1UoQJs4Mop+Dozh1ryWLA0Nqzng9HIvsWkBqLxAm3q5g==", + "requires": { + "axios": "^0.18.0" + } + }, "nextcloud-vue": { "version": "0.1.5", "resolved": "https://registry.npmjs.org/nextcloud-vue/-/nextcloud-vue-0.1.5.tgz", diff --git a/settings/package.json b/settings/package.json index 307649622b..19c3de7df3 100644 --- a/settings/package.json +++ b/settings/package.json @@ -12,7 +12,7 @@ }, "dependencies": { "@babel/polyfill": "^7.0.0", - "axios": "^0.18.0", + "nextcloud-axios": "^0.1.2", "nextcloud-vue": "^0.1.5", "v-tooltip": "^2.0.0-rc.33", "vue": "^2.5.17", diff --git a/settings/src/store/api.js b/settings/src/store/api.js index 8fc4dfde3e..e87dabd493 100644 --- a/settings/src/store/api.js +++ b/settings/src/store/api.js @@ -20,10 +20,7 @@ * */ -import axios from 'axios'; - -const requestToken = document.getElementsByTagName('head')[0].getAttribute('data-requesttoken'); -const tokenHeaders = { headers: { requesttoken: requestToken } }; +import axios from 'nextcloud-axios' const sanitize = function(url) { return url.replace(/\/$/, ''); // Remove last url slash @@ -94,27 +91,27 @@ export default { }); }, get(url) { - return axios.get(sanitize(url), tokenHeaders) + return axios.get(sanitize(url)) .then((response) => Promise.resolve(response)) .catch((error) => Promise.reject(error)); }, post(url, data) { - return axios.post(sanitize(url), data, tokenHeaders) + return axios.post(sanitize(url), data) .then((response) => Promise.resolve(response)) .catch((error) => Promise.reject(error)); }, patch(url, data) { - return axios.patch(sanitize(url), data, tokenHeaders) + return axios.patch(sanitize(url), data) .then((response) => Promise.resolve(response)) .catch((error) => Promise.reject(error)); }, put(url, data) { - return axios.put(sanitize(url), data, tokenHeaders) + return axios.put(sanitize(url), data) .then((response) => Promise.resolve(response)) .catch((error) => Promise.reject(error)); }, delete(url, data) { - return axios.delete(sanitize(url), { data: data, headers: tokenHeaders.headers }) + return axios.delete(sanitize(url), { data: data }) .then((response) => Promise.resolve(response)) .catch((error) => Promise.reject(error)); } diff --git a/settings/src/store/apps.js b/settings/src/store/apps.js index 99bd4af459..287a1c1350 100644 --- a/settings/src/store/apps.js +++ b/settings/src/store/apps.js @@ -21,7 +21,6 @@ */ import api from './api'; -import axios from 'axios/index'; import Vue from 'vue'; const state = {