display error & disable input based on user input

This commit is contained in:
Abdul Rifqi Al Abqary
2020-01-06 16:15:58 +09:00
parent b98d9074bb
commit 2e7e40c4cc

View File

@@ -469,6 +469,7 @@
<li> <li>
<label for="oidc-discovery-url">{{ $t("oidc_discovery_url") }}</label> <label for="oidc-discovery-url">{{ $t("oidc_discovery_url") }}</label>
<input <input
:disabled="this.authUrl !== '' || this.accessTokenUrl !== ''"
id="oidc-discovery-url" id="oidc-discovery-url"
name="oidc_discovery_url" name="oidc_discovery_url"
type="url" type="url"
@@ -481,6 +482,7 @@
<li> <li>
<label for="auth-url">{{ $t("auth_url") }}</label> <label for="auth-url">{{ $t("auth_url") }}</label>
<input <input
:disabled="this.oidcDiscoveryUrl !== ''"
id="auth-url" id="auth-url"
name="auth_url" name="auth_url"
type="url" type="url"
@@ -493,6 +495,7 @@
<li> <li>
<label for="access-token-url">{{ $t("access_token_url") }}</label> <label for="access-token-url">{{ $t("access_token_url") }}</label>
<input <input
:disabled="this.oidcDiscoveryUrl !== ''"
id="access-token-url" id="access-token-url"
name="access_token_url" name="access_token_url"
type="url" type="url"
@@ -2439,17 +2442,28 @@ export default {
} }
}, },
async handleAccessTokenRequest(){ async handleAccessTokenRequest(){
if (this.oidcDiscoveryUrl === "" && (this.authUrl === "" || this.accessTokenUrl === "")) {
this.$toast.error("Please complete configuration urls.", {
icon: "error"
});
return;
}
try {
const tokenReqParams = { const tokenReqParams = {
grantType: "code", grantType: "code",
oidcDiscoveryUrl: this.oidcDiscoveryUrl, oidcDiscoveryUrl: this.oidcDiscoveryUrl,
authUrl: this.authUrl, authUrl: this.authUrl,
accessTokenUrl: this.accessTokenUrl, accessTokenUrl: this.accessTokenUrl,
clientId: this.clientId, clientId: this.clientId,
clientSecret: this.clientSecret,
scope: this.scope, scope: this.scope,
clientAuth: this.clientAuth clientAuth: this.clientAuth
}; };
await tokenRequest(tokenReqParams); await tokenRequest(tokenReqParams);
} catch (e) {
this.$toast.error(e, {
icon: "code"
});
}
}, },
async oauthRedirectReq() { async oauthRedirectReq() {
let tokenInfo = await oauthRedirect(); let tokenInfo = await oauthRedirect();