diff --git a/pages/index.vue b/pages/index.vue index 05b38a186..8e9c5b041 100644 --- a/pages/index.vue +++ b/pages/index.vue @@ -994,13 +994,50 @@ -
+
+
@@ -1425,12 +1462,12 @@ export default { this.$store.commit("setState", { value, attribute: "bearerToken" }); } }, - token: { + tokens: { get() { - return this.$store.oauth2.token; + return this.$store.state.oauth2.tokens; }, set(value) { - this.$store.commit("setOauth2", { value, attribute: "token" }); + this.$store.commit("setOAuth2", { value, attribute: "tokens" }); } }, accessTokenName: { @@ -1438,7 +1475,7 @@ export default { return this.$store.state.oauth2.accessTokenName; }, set(value) { - this.$store.commit("setOauth2", { value, attribute: "accessTokenName" }); + this.$store.commit("setOAuth2", { value, attribute: "accessTokenName" }); } }, oidcDiscoveryUrl: { @@ -1446,7 +1483,7 @@ export default { return this.$store.state.oauth2.oidcDiscoveryUrl; }, set(value) { - this.$store.commit("setOauth2", { value, attribute: "oidcDiscoveryUrl" }); + this.$store.commit("setOAuth2", { value, attribute: "oidcDiscoveryUrl" }); } }, authUrl: { @@ -1454,7 +1491,7 @@ export default { return this.$store.state.oauth2.authUrl; }, set(value) { - this.$store.commit("setOauth2", { value, attribute: "authUrl" }); + this.$store.commit("setOAuth2", { value, attribute: "authUrl" }); } }, accessTokenUrl: { @@ -1462,7 +1499,7 @@ export default { return this.$store.state.oauth2.accessTokenUrl; }, set(value) { - this.$store.commit("setOauth2", { value, attribute: "accessTokenUrl" }); + this.$store.commit("setOAuth2", { value, attribute: "accessTokenUrl" }); } }, clientId: { @@ -1470,7 +1507,7 @@ export default { return this.$store.state.oauth2.clientId; }, set(value) { - this.$store.commit("setOauth2", { value, attribute: "clientId" }); + this.$store.commit("setOAuth2", { value, attribute: "clientId" }); } }, scope: { @@ -1478,7 +1515,7 @@ export default { return this.$store.state.oauth2.scope; }, set(value) { - this.$store.commit("setOauth2", { value, attribute: "scope" }); + this.$store.commit("setOAuth2", { value, attribute: "scope" }); } }, state: { @@ -1486,7 +1523,7 @@ export default { return this.$store.state.oauth2.state; }, set(value) { - this.$store.commit("setOauth2", { value, attribute: "state" }); + this.$store.commit("setOAuth2", { value, attribute: "state" }); } }, headers: { @@ -2470,6 +2507,29 @@ export default { this.bearerToken = tokenInfo.access_token; } }, + addOAuthToken() { + this.$store.commit("addOAuthToken", { + name: "", + value: "" + }); + return false; + }, + removeOAuthToken(index) { + // .slice() gives us an entirely new array rather than giving us just the reference + const oldTokens = this.tokens.slice(); + + this.$store.commit("removeOAuthToken", index); + this.$toast.error("Deleted", { + icon: "delete", + action: { + text: "Undo", + onClick: (e, toastObject) => { + this.tokens = oldTokens; + toastObject.remove(); + } + } + }); + }, saveToken(){ try { this.$toast.info("Access token saved"); diff --git a/store/mutations.js b/store/mutations.js index 67d17b696..bc76a5b93 100644 --- a/store/mutations.js +++ b/store/mutations.js @@ -87,7 +87,24 @@ export default { request.bodyParams[index].value = value; }, - setOauth2({ oauth2 }, { attribute, value }) { + setOAuth2({ oauth2 }, { attribute, value }) { oauth2[attribute] = value; - } + }, + + addOAuthToken({ oauth2 }, value) { + oauth2.tokens.push(value); + }, + + removeOAuthToken({ oauth2 }, index) { + oauth2.tokens.splice(index, 1); + }, + + setOAuthTokenName({ oauth2 }, { index, value }) { + oauth2.tokens[index].name = value; + }, + + setOAuthTokenValue({ oauth2 }, { index, value }) { + oauth2.tokens[index].value = value; + }, + }; diff --git a/store/state.js b/store/state.js index ed9467f1b..e5cb1c089 100644 --- a/store/state.js +++ b/store/state.js @@ -24,7 +24,7 @@ export default () => ({ query: "" }, oauth2: { - token: [], + tokens: [], accessTokenName: "", oidcDiscoveryUrl: "", authUrl: "",