diff --git a/resources/js/views/Register.vue b/resources/js/views/Register.vue
index 2802599c..19812d71 100644
--- a/resources/js/views/Register.vue
+++ b/resources/js/views/Register.vue
@@ -7,26 +7,30 @@
+
+
+ {{ errorMessage }}
+
@@ -43,16 +51,30 @@
export default {
data(){
return {
- name : "",
- email : "",
- password : "",
- password_confirmation : ""
+ name : '',
+ nameMissing : false,
+ email : '',
+ emailMissing : false,
+ password : '',
+ passwordMissing : false,
+ password_confirmation : '',
+ passwordConfirmationMissing : false,
+ errorMessage : '',
}
},
methods : {
handleSubmit(e) {
e.preventDefault()
+ this.nameMissing = (this.name.length === 0) ? true : false;
+ this.emailMissing = (this.email.length === 0) ? true : false;
+ this.passwordMissing = (this.password.length === 0) ? true : false;
+ this.passwordConfirmationMissing = (this.password_confirmation.length === 0) ? true : false;
+
+ if( this.nameMissing || this.emailMissing || this.passwordMissing || this.passwordConfirmationMissing ) {
+ return false;
+ }
+
if (this.password === this.password_confirmation && this.password.length > 0)
{
axios.post('api/register', {
@@ -66,17 +88,16 @@
localStorage.setItem('jwt',response.data.success.token)
if (localStorage.getItem('jwt') != null){
- this.$router.go('/')
+ this.$router.push({name: 'accounts'});
}
})
.catch(error => {
console.error(error);
+ this.errorMessage = error.message
});
} else {
- this.password = ""
- this.passwordConfirm = ""
-
- return alert('Passwords do not match')
+ this.errorMessage = 'Passwords do not match'
+ return false;
}
}
},