added token managements
This commit is contained in:
@@ -994,13 +994,50 @@
|
|||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
<div slot="body">
|
<div slot="body" ref="tokens">
|
||||||
|
<ul v-for="(token, index) in tokens" :key="index">
|
||||||
|
<li>
|
||||||
|
<input
|
||||||
|
:placeholder="'name ' + (index + 1)"
|
||||||
|
:value="token.name"
|
||||||
|
@change="
|
||||||
|
$store.commit('setOAuthTokenName', {
|
||||||
|
index,
|
||||||
|
value: $event.target.value
|
||||||
|
})
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
<li>
|
||||||
|
<input
|
||||||
|
:placeholder="'value ' + (index + 1)"
|
||||||
|
:name="'value' + index"
|
||||||
|
:value="token.value"
|
||||||
|
@change="
|
||||||
|
$store.commit('setOAuthTokenValue', {
|
||||||
|
index,
|
||||||
|
value: $event.target.value
|
||||||
|
})
|
||||||
|
"
|
||||||
|
/>
|
||||||
|
</li>
|
||||||
|
<div>
|
||||||
|
<li>
|
||||||
|
<button
|
||||||
|
class="icon"
|
||||||
|
@click="removeOAuthToken(index)"
|
||||||
|
>
|
||||||
|
<i class="material-icons">delete</i>
|
||||||
|
</button>
|
||||||
|
</li>
|
||||||
|
</div>
|
||||||
|
</ul>
|
||||||
<ul>
|
<ul>
|
||||||
<li>
|
<li>
|
||||||
<textarea
|
<button class="icon" @click="addOAuthToken">
|
||||||
rows="8"
|
<i class="material-icons">add</i>
|
||||||
placeholder="Token list"
|
<span>{{ $t("add_new") }}</span>
|
||||||
></textarea>
|
</button>
|
||||||
</li>
|
</li>
|
||||||
</ul>
|
</ul>
|
||||||
</div>
|
</div>
|
||||||
@@ -1425,12 +1462,12 @@ export default {
|
|||||||
this.$store.commit("setState", { value, attribute: "bearerToken" });
|
this.$store.commit("setState", { value, attribute: "bearerToken" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
token: {
|
tokens: {
|
||||||
get() {
|
get() {
|
||||||
return this.$store.oauth2.token;
|
return this.$store.state.oauth2.tokens;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setOauth2", { value, attribute: "token" });
|
this.$store.commit("setOAuth2", { value, attribute: "tokens" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
accessTokenName: {
|
accessTokenName: {
|
||||||
@@ -1438,7 +1475,7 @@ export default {
|
|||||||
return this.$store.state.oauth2.accessTokenName;
|
return this.$store.state.oauth2.accessTokenName;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setOauth2", { value, attribute: "accessTokenName" });
|
this.$store.commit("setOAuth2", { value, attribute: "accessTokenName" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
oidcDiscoveryUrl: {
|
oidcDiscoveryUrl: {
|
||||||
@@ -1446,7 +1483,7 @@ export default {
|
|||||||
return this.$store.state.oauth2.oidcDiscoveryUrl;
|
return this.$store.state.oauth2.oidcDiscoveryUrl;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setOauth2", { value, attribute: "oidcDiscoveryUrl" });
|
this.$store.commit("setOAuth2", { value, attribute: "oidcDiscoveryUrl" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
authUrl: {
|
authUrl: {
|
||||||
@@ -1454,7 +1491,7 @@ export default {
|
|||||||
return this.$store.state.oauth2.authUrl;
|
return this.$store.state.oauth2.authUrl;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setOauth2", { value, attribute: "authUrl" });
|
this.$store.commit("setOAuth2", { value, attribute: "authUrl" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
accessTokenUrl: {
|
accessTokenUrl: {
|
||||||
@@ -1462,7 +1499,7 @@ export default {
|
|||||||
return this.$store.state.oauth2.accessTokenUrl;
|
return this.$store.state.oauth2.accessTokenUrl;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setOauth2", { value, attribute: "accessTokenUrl" });
|
this.$store.commit("setOAuth2", { value, attribute: "accessTokenUrl" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
clientId: {
|
clientId: {
|
||||||
@@ -1470,7 +1507,7 @@ export default {
|
|||||||
return this.$store.state.oauth2.clientId;
|
return this.$store.state.oauth2.clientId;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setOauth2", { value, attribute: "clientId" });
|
this.$store.commit("setOAuth2", { value, attribute: "clientId" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
scope: {
|
scope: {
|
||||||
@@ -1478,7 +1515,7 @@ export default {
|
|||||||
return this.$store.state.oauth2.scope;
|
return this.$store.state.oauth2.scope;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setOauth2", { value, attribute: "scope" });
|
this.$store.commit("setOAuth2", { value, attribute: "scope" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
state: {
|
state: {
|
||||||
@@ -1486,7 +1523,7 @@ export default {
|
|||||||
return this.$store.state.oauth2.state;
|
return this.$store.state.oauth2.state;
|
||||||
},
|
},
|
||||||
set(value) {
|
set(value) {
|
||||||
this.$store.commit("setOauth2", { value, attribute: "state" });
|
this.$store.commit("setOAuth2", { value, attribute: "state" });
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
headers: {
|
headers: {
|
||||||
@@ -2470,6 +2507,29 @@ export default {
|
|||||||
this.bearerToken = tokenInfo.access_token;
|
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(){
|
saveToken(){
|
||||||
try {
|
try {
|
||||||
this.$toast.info("Access token saved");
|
this.$toast.info("Access token saved");
|
||||||
|
|||||||
@@ -87,7 +87,24 @@ export default {
|
|||||||
request.bodyParams[index].value = value;
|
request.bodyParams[index].value = value;
|
||||||
},
|
},
|
||||||
|
|
||||||
setOauth2({ oauth2 }, { attribute, value }) {
|
setOAuth2({ oauth2 }, { attribute, value }) {
|
||||||
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;
|
||||||
|
},
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ export default () => ({
|
|||||||
query: ""
|
query: ""
|
||||||
},
|
},
|
||||||
oauth2: {
|
oauth2: {
|
||||||
token: [],
|
tokens: [],
|
||||||
accessTokenName: "",
|
accessTokenName: "",
|
||||||
oidcDiscoveryUrl: "",
|
oidcDiscoveryUrl: "",
|
||||||
authUrl: "",
|
authUrl: "",
|
||||||
|
|||||||
Reference in New Issue
Block a user