Skip to content

Commit

Permalink
fix error in register page
Browse files Browse the repository at this point in the history
fix lesspass/lesspass#66
Malformed email causes bad error message when registering
  • Loading branch information
guillaumevincent committed Nov 13, 2016
1 parent 96b5fa3 commit 6ef1e5c
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
v-model="email">
<small class="form-text text-muted text-danger">
<span v-if="errors.userNameAlreadyExist">Someone already use that username. Do you want to sign in ?</span>
<span v-if="errors.emailInvalid">Please enter a valid email</span>
<span v-if="errors.emailRequired">An email is required</span>
</small>
</div>
Expand Down Expand Up @@ -87,6 +88,7 @@
const defaultErrors = {
userNameAlreadyExist: false,
emailInvalid: false,
baseURLRequired: false,
emailRequired: false,
passwordRequired: false,
Expand All @@ -109,7 +111,7 @@
},
methods: {
noErrors(){
return !(this.errors.userNameAlreadyExist || this.errors.emailRequired || this.errors.passwordRequired || this.errors.baseURLRequired || this.showError);
return !(this.errors.userNameAlreadyExist || this.errors.emailInvalid || this.errors.emailRequired || this.errors.passwordRequired || this.errors.baseURLRequired || this.showError);
},
formIsValid(){
this.cleanErrors();
Expand Down Expand Up @@ -157,7 +159,7 @@
this.showErrorMessage('Your LessPass Database is not running');
}
} else if (err.response.status === 400) {
this.showErrorMessage('Your email and/or password is not good. Do you have an account ?');
this.showErrorMessage('Your email and/or password is not good. Do you have an account?');
} else {
this.showErrorMessage()
}
Expand All @@ -177,8 +179,13 @@
})
.catch(err => {
this.cleanErrors();
if (err.response && (err.response.data.email[0].indexOf('already exists') !== -1)) {
this.errors.userNameAlreadyExist = true;
if (err.response && typeof err.response.data.email !== 'undefined') {
if (err.response.data.email[0].indexOf('already exists') !== -1) {
this.errors.userNameAlreadyExist = true;
}
if (err.response.data.email[0].indexOf('valid email') !== -1) {
this.errors.emailInvalid = true;
}
} else {
this.showErrorMessage();
}
Expand Down

0 comments on commit 6ef1e5c

Please sign in to comment.