Browse Source

fix error in register page

fix https://github.com/lesspass/lesspass/issues/66
Malformed email causes bad error message when registering
pull/342/head
Guillaume Vincent 8 years ago
parent
commit
6ef1e5cf96
1 changed files with 11 additions and 4 deletions
  1. +11
    -4
      src/views/Login.vue

+ 11
- 4
src/views/Login.vue View File

@@ -18,6 +18,7 @@
v-model="email"> v-model="email">
<small class="form-text text-muted text-danger"> <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.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> <span v-if="errors.emailRequired">An email is required</span>
</small> </small>
</div> </div>
@@ -87,6 +88,7 @@


const defaultErrors = { const defaultErrors = {
userNameAlreadyExist: false, userNameAlreadyExist: false,
emailInvalid: false,
baseURLRequired: false, baseURLRequired: false,
emailRequired: false, emailRequired: false,
passwordRequired: false, passwordRequired: false,
@@ -109,7 +111,7 @@
}, },
methods: { methods: {
noErrors(){ 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(){ formIsValid(){
this.cleanErrors(); this.cleanErrors();
@@ -157,7 +159,7 @@
this.showErrorMessage('Your LessPass Database is not running'); this.showErrorMessage('Your LessPass Database is not running');
} }
} else if (err.response.status === 400) { } 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 { } else {
this.showErrorMessage() this.showErrorMessage()
} }
@@ -177,8 +179,13 @@
}) })
.catch(err => { .catch(err => {
this.cleanErrors(); 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 { } else {
this.showErrorMessage(); this.showErrorMessage();
} }


Loading…
Cancel
Save