Switch to nextcloud-axios for oauth2 app

Signed-off-by: Roeland Jago Douma <roeland@famdouma.nl>
This commit is contained in:
Roeland Jago Douma 2018-12-07 13:57:50 +01:00
parent 1f492322a8
commit c1f1dd18fc
No known key found for this signature in database
GPG Key ID: F941078878347C0C
5 changed files with 27 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1529,7 +1529,8 @@
"ansi-regex": { "ansi-regex": {
"version": "2.1.1", "version": "2.1.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"aproba": { "aproba": {
"version": "1.2.0", "version": "1.2.0",
@ -1944,7 +1945,8 @@
"safe-buffer": { "safe-buffer": {
"version": "5.1.1", "version": "5.1.1",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"safer-buffer": { "safer-buffer": {
"version": "2.1.2", "version": "2.1.2",
@ -2000,6 +2002,7 @@
"version": "3.0.1", "version": "3.0.1",
"bundled": true, "bundled": true,
"dev": true, "dev": true,
"optional": true,
"requires": { "requires": {
"ansi-regex": "^2.0.0" "ansi-regex": "^2.0.0"
} }
@ -2043,12 +2046,14 @@
"wrappy": { "wrappy": {
"version": "1.0.2", "version": "1.0.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
}, },
"yallist": { "yallist": {
"version": "3.0.2", "version": "3.0.2",
"bundled": true, "bundled": true,
"dev": true "dev": true,
"optional": true
} }
} }
}, },
@ -2854,6 +2859,14 @@
"integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==", "integrity": "sha512-MFh0d/Wa7vkKO3Y3LlacqAEeHK0mckVqzDieUKTT+KGxi+zIpeVsFxymkIiRpbpDziHc290Xr9A1O4Om7otoRA==",
"dev": true "dev": true
}, },
"nextcloud-axios": {
"version": "0.1.3",
"resolved": "https://registry.npmjs.org/nextcloud-axios/-/nextcloud-axios-0.1.3.tgz",
"integrity": "sha512-M2eLX0qrP8xy1VEGDhPXGwvV4W4gMnU1ysjnURVen8ehR1qRLdb/JfhJHab6XRsme7vWWMgSTEj+o3ibQ94N6g==",
"requires": {
"axios": "^0.18.0"
}
},
"nice-try": { "nice-try": {
"version": "1.0.5", "version": "1.0.5",
"resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz", "resolved": "https://registry.npmjs.org/nice-try/-/nice-try-1.0.5.tgz",

View File

@ -16,7 +16,7 @@
"test": "echo \"Error: no test specified\" && exit 1" "test": "echo \"Error: no test specified\" && exit 1"
}, },
"dependencies": { "dependencies": {
"axios": "^0.18.0", "nextcloud-axios": "^0.1.3",
"vue": "^2.5.17" "vue": "^2.5.17"
}, },
"devDependencies": { "devDependencies": {

View File

@ -54,7 +54,7 @@
</template> </template>
<script> <script>
import axios from 'axios'; import Axios from 'nextcloud-axios'
import OAuthItem from './components/OAuthItem'; import OAuthItem from './components/OAuthItem';
export default { export default {
@ -74,36 +74,27 @@ export default {
}; };
}, },
beforeMount: function() { beforeMount: function() {
let requestToken = OC.requestToken; Axios.get(OC.generateUrl('apps/oauth2/clients'))
let tokenHeaders = { headers: { requesttoken: requestToken } };
axios.get(OC.generateUrl('apps/oauth2/clients'), tokenHeaders)
.then((response) => { .then((response) => {
this.clients = response.data; this.clients = response.data;
}); });
}, },
methods: { methods: {
deleteClient(id) { deleteClient(id) {
let requestToken = OC.requestToken; Axios.delete(OC.generateUrl('apps/oauth2/clients/{id}', {id: id}))
let tokenHeaders = { headers: { requesttoken: requestToken } };
axios.delete(OC.generateUrl('apps/oauth2/clients/{id}', {id: id}), tokenHeaders)
.then((response) => { .then((response) => {
this.clients = this.clients.filter(client => client.id !== id); this.clients = this.clients.filter(client => client.id !== id);
}); });
}, },
addClient() { addClient() {
let requestToken = OC.requestToken;
let tokenHeaders = { headers: { requesttoken: requestToken } };
this.newClient.error = false; this.newClient.error = false;
axios.post( Axios.post(
OC.generateUrl('apps/oauth2/clients'), OC.generateUrl('apps/oauth2/clients'),
{ {
name: this.newClient.name, name: this.newClient.name,
redirectUri: this.newClient.redirectUri redirectUri: this.newClient.redirectUri
}, }
tokenHeaders
).then(response => { ).then(response => {
this.clients.push(response.data); this.clients.push(response.data);