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 @@
{{ $t("login.forgotpassword.success.msg")}}
</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 }}
</div>
</form>
......@@ -152,10 +152,9 @@
headers: jsonHeader,
}).then((response) => {
if (response.status != 200 && response.status != 201) {
this.createError(response.status)
this.$root.sharedState.uuid = '';
} else {
this.removeError();
this.getUserFromStorage();
/** Sync Operation for valid timestamp */
this.$refs.Sync.syncOneWayDifferentTimeStamp(this.appUser);
......@@ -173,7 +172,7 @@
},
/** Login process . sending user credential */
handleLogin() {
this.showForgottenPasswordSubmitSuccessMsg = false;
this.showForgottenPasswordSubmitSuccessMsg = false;
this.removeError();
let This = this;
......@@ -182,7 +181,7 @@
// Validate input
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
}
let jsonBody = JSON.stringify({"username": this.username, "password": this.password});
......@@ -203,7 +202,7 @@
return response.json();
}
else {
This.createError(response.status);
This.createLoginError(response.status);
return false;
}
})
......@@ -287,7 +286,7 @@
this.removeError();
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;
}
const formData = new URLSearchParams();
......@@ -341,12 +340,14 @@
this.submitFailed = false;
this.errorMessage = undefined;
},
createError(status, message) {
createLoginError(status, message) {
this.submitFailed = true;
if(message) {
this.errorMessage = message;
} else if (status === 500 || status === 503) {
this.errorMessage = this.$i18n.t("login.systems.server.error");
} else if(status === 404) {
this.errorMessage = this.$i18n.t("login.systems.wrong.credential");
} else {
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