Browse Source

fix errors with buttons in login page

pull/342/head
Guillaume Vincent 8 years ago
parent
commit
ffe64e722a
3 changed files with 31 additions and 41 deletions
  1. +6
    -6
      src/components/ForgotPassword.vue
  2. +19
    -29
      src/components/Login.vue
  3. +6
    -6
      src/components/Register.vue

+ 6
- 6
src/components/ForgotPassword.vue View File

@@ -9,7 +9,7 @@
<div class="row"> <div class="row">
<div class="login-header"> <div class="login-header">
<div class="col-xs-1"> <div class="col-xs-1">
<span class="link" v-on:click="go('index')">
<span class="link" v-on:click="go('login')">
<i class="fa fa-chevron-circle-left white" aria-hidden="true"></i> <i class="fa fa-chevron-circle-left white" aria-hidden="true"></i>
</span> </span>
</div> </div>
@@ -21,7 +21,7 @@
</div> </div>
<div class="card-block"> <div class="card-block">
<form v-on:submit.prevent="forgotPassword"> <form v-on:submit.prevent="forgotPassword">
<div class="form-group row" v-if="errorMessage">
<div class="form-group row" v-if="showError">
<div class="col-xs-12 text-muted text-danger"> <div class="col-xs-12 text-muted text-danger">
Oops! Something went wrong. Retry in a few minutes. Oops! Something went wrong. Retry in a few minutes.
</div> </div>
@@ -72,18 +72,18 @@
storage, storage,
email: '', email: '',
emailRequired: false, emailRequired: false,
errorMessage: false,
showError: false,
successMessage: false, successMessage: false,
}; };
}, },
methods: Object.assign(mapActions(['go']), { methods: Object.assign(mapActions(['go']), {
cleanErrors(){ cleanErrors(){
this.emailRequired = false; this.emailRequired = false;
this.errorMessage = false;
this.showError = false;
this.successMessage = false; this.successMessage = false;
}, },
noErrors(){ noErrors(){
return !(this.emailRequired || this.errorMessage);
return !(this.emailRequired || this.showError);
}, },
forgotPassword(){ forgotPassword(){
this.cleanErrors(); this.cleanErrors();
@@ -94,7 +94,7 @@
this.auth.resetPassword({email: this.email}).then(()=> { this.auth.resetPassword({email: this.email}).then(()=> {
this.successMessage = true this.successMessage = true
}).catch(err => { }).catch(err => {
this.errorMessage = true;
this.showError = true;
}); });
} }
}) })


+ 19
- 29
src/components/Login.vue View File

@@ -10,14 +10,6 @@
top: 0; top: 0;
left: 0; left: 0;
} }

.fade-enter-active, .fade-leave-active {
transition: opacity .5s
}

.fade-enter, .fade-leave-active {
opacity: 0
}
</style> </style>
<template> <template>
<div> <div>
@@ -36,12 +28,12 @@
</div> </div>
</div> </div>
<div class="card-block"> <div class="card-block">
<transition name="fade">
<div class="alert alert-danger" role="alert" v-if="showError">
{{ errorMessage }}
</div>
</transition>
<form v-on:submit.prevent="login"> <form v-on:submit.prevent="login">
<div class="form-group row" v-if="showError">
<div class="col-xs-12 text-muted text-danger">
{{ errorMessage }}
</div>
</div>
<div class="form-group row"> <div class="form-group row">
<div class="col-xs-12"> <div class="col-xs-12">
<div class="inner-addon left-addon"> <div class="inner-addon left-addon">
@@ -84,21 +76,15 @@
<button id="loginButton" class="btn btn-primary" type="submit"> <button id="loginButton" class="btn btn-primary" type="submit">
Sign In Sign In
</button> </button>
<button id="registerButton" class="btn btn-secondary" type="button" v-on:click="go('register')">
Register
</button>
</div> </div>
</div> </div>
<div class="form-group row"> <div class="form-group row">
<ul class="list-unstyled">
<li>
<button class="btn btn-link" v-on:click="go('register')">
Do not have an account ? Register
</button>
</li>
<li>
<button class="btn btn-link" v-on:click="go('forgotPassword')">
Forgot you password ?
</button>
</li>
</ul>
<button class="btn btn-link" type="button" v-on:click="go('forgotPassword')">
Forgot you password ?
</button>
</div> </div>
</form> </form>
</div> </div>
@@ -130,11 +116,15 @@
this.errorMessage = errorMessage; this.errorMessage = errorMessage;
this.showError = true; this.showError = true;
setTimeout(() => { setTimeout(() => {
this.showError = false;
this.errorMessage = '';
}, 4000);
this.cleanErrors();
}, 6000);
},
cleanErrors(){
this.showError = false;
this.errorMessage = '';
}, },
login(){ login(){
this.cleanErrors();
var baseURL = this.baseURL; var baseURL = this.baseURL;
var email = this.user.email; var email = this.user.email;
if (!email || !this.user.password || !baseURL) { if (!email || !this.user.password || !baseURL) {
@@ -151,7 +141,7 @@
.catch(err => { .catch(err => {
if (err.response === undefined) { if (err.response === undefined) {
if (baseURL === "https://lesspass.com") { if (baseURL === "https://lesspass.com") {
this.showErrorMessage('LessPass Database is not running. Sorry for the inconvenience.');
this.showErrorMessage('Oops! Something went wrong. Retry in a few minutes.');
} else { } else {
this.showErrorMessage('Your LessPass Database is not running'); this.showErrorMessage('Your LessPass Database is not running');
} }


+ 6
- 6
src/components/Register.vue View File

@@ -9,7 +9,7 @@
<div class="row"> <div class="row">
<div class="login-header"> <div class="login-header">
<div class="col-xs-1"> <div class="col-xs-1">
<span class="link" v-on:click="go('index')">
<span class="link" v-on:click="go('login')">
<i class="fa fa-chevron-circle-left white" aria-hidden="true"></i> <i class="fa fa-chevron-circle-left white" aria-hidden="true"></i>
</span> </span>
</div> </div>
@@ -21,7 +21,7 @@
</div> </div>
<div class="card-block"> <div class="card-block">
<form v-on:submit.prevent="register"> <form v-on:submit.prevent="register">
<div class="form-group row" v-if="errorMessage">
<div class="form-group row" v-if="showError">
<div class="col-xs-12 text-muted text-danger"> <div class="col-xs-12 text-muted text-danger">
Oops! Something went wrong. Retry in a few minutes. Oops! Something went wrong. Retry in a few minutes.
</div> </div>
@@ -90,7 +90,7 @@
userNameAlreadyExist: false, userNameAlreadyExist: false,
emailRequired: false, emailRequired: false,
passwordRequired: false, passwordRequired: false,
errorMessage: false
showError: false
}; };
}, },
methods: Object.assign(mapActions(['go']), { methods: Object.assign(mapActions(['go']), {
@@ -98,10 +98,10 @@
this.userNameAlreadyExist = false; this.userNameAlreadyExist = false;
this.emailRequired = false; this.emailRequired = false;
this.passwordRequired = false; this.passwordRequired = false;
this.errorMessage = false;
this.showError = false;
}, },
noErrors(){ noErrors(){
return !(this.userNameAlreadyExist || this.emailRequired || this.passwordRequired || this.errorMessage);
return !(this.userNameAlreadyExist || this.emailRequired || this.passwordRequired || this.showError);
}, },
register(){ register(){
this.cleanErrors(); this.cleanErrors();
@@ -121,7 +121,7 @@
if (err.response && (err.response.data.email[0].indexOf('already exists') !== -1)) { if (err.response && (err.response.data.email[0].indexOf('already exists') !== -1)) {
this.userNameAlreadyExist = true this.userNameAlreadyExist = true
} else { } else {
this.errorMessage = true;
this.showError = true;
} }
}); });
} }


Loading…
Cancel
Save