Skip to content
Snippets Groups Projects
Commit 2104e8d3 authored by Lene Wasskog's avatar Lene Wasskog
Browse files

feat: Add extra condition before displaying error message

parent b9a12f76
No related branches found
No related tags found
No related merge requests found
...@@ -77,7 +77,7 @@ ...@@ -77,7 +77,7 @@
{{ $t("login.forgotpassword.success.msg")}} {{ $t("login.forgotpassword.success.msg")}}
</div> </div>
<div v-if="submitFailed" class="form-group alert alert-danger mt-4"> <div v-if="submitFailed && errorMessage" class="form-group alert alert-danger mt-4">
{{ errorMessage }} {{ errorMessage }}
</div> </div>
</form> </form>
...@@ -152,10 +152,9 @@ ...@@ -152,10 +152,9 @@
headers: jsonHeader, headers: jsonHeader,
}).then((response) => { }).then((response) => {
if (response.status != 200 && response.status != 201) { if (response.status != 200 && response.status != 201) {
this.createError(response.status)
this.$root.sharedState.uuid = ''; this.$root.sharedState.uuid = '';
} else { } else {
this.removeError();
this.getUserFromStorage(); this.getUserFromStorage();
/** Sync Operation for valid timestamp */ /** Sync Operation for valid timestamp */
this.$refs.Sync.syncOneWayDifferentTimeStamp(this.appUser); this.$refs.Sync.syncOneWayDifferentTimeStamp(this.appUser);
...@@ -173,7 +172,7 @@ ...@@ -173,7 +172,7 @@
}, },
/** Login process . sending user credential */ /** Login process . sending user credential */
handleLogin() { handleLogin() {
this.showForgottenPasswordSubmitSuccessMsg = false; this.showForgottenPasswordSubmitSuccessMsg = false;
this.removeError(); this.removeError();
let This = this; let This = this;
...@@ -182,7 +181,7 @@ ...@@ -182,7 +181,7 @@
// Validate input // Validate input
if (!this.username || !this.password) { if (!this.username || !this.password) {
this.createError(-1, this.$i18n.t("login.systems.user.password.required")) this.createLoginError(-1, this.$i18n.t("login.systems.user.password.required"))
return return
} }
let jsonBody = JSON.stringify({"username": this.username, "password": this.password}); let jsonBody = JSON.stringify({"username": this.username, "password": this.password});
...@@ -203,7 +202,7 @@ ...@@ -203,7 +202,7 @@
return response.json(); return response.json();
} }
else { else {
This.createError(response.status); This.createLoginError(response.status);
return false; return false;
} }
}) })
...@@ -287,7 +286,7 @@ ...@@ -287,7 +286,7 @@
this.removeError(); this.removeError();
if(!this.email || this.email.indexOf("@") < 0) { if(!this.email || this.email.indexOf("@") < 0) {
this.createError(-1, this.$i18n.t("login.systems.invalid.email")); this.createLoginError(-1, this.$i18n.t("login.systems.invalid.email"));
return; return;
} }
const formData = new URLSearchParams(); const formData = new URLSearchParams();
...@@ -341,12 +340,14 @@ ...@@ -341,12 +340,14 @@
this.submitFailed = false; this.submitFailed = false;
this.errorMessage = undefined; this.errorMessage = undefined;
}, },
createError(status, message) { createLoginError(status, message) {
this.submitFailed = true; this.submitFailed = true;
if(message) { if(message) {
this.errorMessage = message; this.errorMessage = message;
} else if (status === 500 || status === 503) { } else if (status === 500 || status === 503) {
this.errorMessage = this.$i18n.t("login.systems.server.error"); this.errorMessage = this.$i18n.t("login.systems.server.error");
} else if(status === 404) {
this.errorMessage = this.$i18n.t("login.systems.wrong.credential");
} else { } else {
this.errorMessage = "Error " + status; this.errorMessage = "Error " + status;
} }
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment