diff --git a/src/themes/ivpn-v3/assets/js/views/Account/WireguardConfig.vue b/src/themes/ivpn-v3/assets/js/views/Account/WireguardConfig.vue
index e7f775573..3e0a0fafa 100644
--- a/src/themes/ivpn-v3/assets/js/views/Account/WireguardConfig.vue
+++ b/src/themes/ivpn-v3/assets/js/views/Account/WireguardConfig.vue
@@ -70,7 +70,8 @@
{{ keyComment }}
- {{ error.addKey }}
+ {{ error.addKey }}
+ {{ error.noKey }}
2. Select one or multiple exit servers
A separate configuration file will be generated for each location that you include.
@@ -129,6 +130,7 @@
+ {{ error.exitLocation }}
3. Configuration
Port
@@ -189,8 +191,8 @@
4. Download
- Download zip archive
- Generate QR code
+ Download zip archive
+ Generate QR code
@@ -238,6 +240,8 @@ export default {
},
error: {
addKey: null,
+ noKey: null,
+ exitLocation: null,
},
isKeyGenerated: true,
multihop: false,
@@ -404,6 +408,7 @@ export default {
this.multihop_port = null;
this.wg_public_key = null;
} else {
+ this.error.exitLocation = null;
this.query.host = value.split("_")[0];
this.multihop_port = value.split("_")[1];
this.wg_public_key = value.split("_")[2];
@@ -529,6 +534,7 @@ export default {
},
async handleDownload() {
if (this.validation.download) {
+ this.handleErrorsOnDownload();
return;
}
@@ -537,12 +543,29 @@ export default {
},
async handleGenerateQRCode() {
if (this.validation.downloadQR) {
+ this.handleErrorsOnDownload();
return;
}
let res = await Api.getWireGuardConfigurations(this.queryString);
this.generateQRCode(res);
},
+ handleErrorsOnDownload() {
+ const isWireguardKeyProvided = this.publicKey != null && this.privateKey != null;
+ const isExitServerSelected = this.host != null && this.host != "";
+ // First all errors are set, only then we proceed to focus them in their markup order
+ if (!isWireguardKeyProvided) {
+ this.error.noKey = "WireGuard key is required for the download.";
+ }
+ if (!isExitServerSelected) {
+ this.error.exitLocation = "Exit server is required for the download.";
+ }
+ if (!isWireguardKeyProvided) {
+ this.$refs.errorNoKey.focus();
+ } else if (!isExitServerSelected) {
+ this.$refs.errorExitLocation.focus();
+ }
+ },
generateKey() {
let keypair = wireguard.generateKeypair();
this.privateKey = keypair.privateKey;
@@ -553,6 +576,7 @@ export default {
this.setKey(this.publicKeyAdd, this.keyComment);
},
async setKey(publicKey, keyComment) {
+ this.error.noKey = null;
try {
let res = await Api.addWireguardKey({
public_key: publicKey,