From 82cf57ad118c48608fbf5ae5994eb370113a379a Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 2 Dec 2020 08:14:00 +0100 Subject: [PATCH] Improve login flow when cors-errors are likely --- src/components/Login.vue | 37 +++++++++++++++++++++++++++---------- 1 file changed, 27 insertions(+), 10 deletions(-) diff --git a/src/components/Login.vue b/src/components/Login.vue index 0801feb7..1553b4e4 100644 --- a/src/components/Login.vue +++ b/src/components/Login.vue @@ -1,5 +1,5 @@ @@ -88,6 +95,8 @@ export default class Login extends Vue { errorMessage = ''; + errorMessageCORS = false; + checkFormValidity() { const valid = this.$refs.form.checkValidity(); this.nameState = valid; @@ -141,16 +150,20 @@ export default class Login extends Vue { } }) .catch((error) => { + this.errorMessageCORS = false; // this.nameState = false; console.log(error.response); if (error.response && error.response.status === 401) { this.nameState = false; - this.errorMessage = 'Login failed, Username or Password wrong.'; + this.errorMessage = 'Connected to bot, however Login failed, Username or Password wrong.'; } else { this.urlState = false; this.errorMessage = `Login failed. - Please verify that the bot is running, the Bot API is enabled and the URL is reachable. - You can try this by going to http://${this.auth.url}/api/v1/ping`; +Please verify that the bot is running, the Bot API is enabled and the URL is reachable. +You can verify this by navigating to ${this.auth.url}/api/v1/ping to make sure the bot API is reachable`; + if (this.auth.url !== window.location.origin) { + this.errorMessageCORS = true; + } } console.log(this.errorMessage); this.emitLoginResult(false); @@ -159,4 +172,8 @@ export default class Login extends Vue { } - +