From 015d67cf738e4ad6d397824dc09a44d85d643b75 Mon Sep 17 00:00:00 2001 From: Mateja Date: Thu, 29 Jul 2021 02:46:33 +0200 Subject: Fully implement client-side login system... --- client/src/views/Register.vue | 32 +++++++++++++++++++++++++++----- 1 file changed, 27 insertions(+), 5 deletions(-) (limited to 'client/src/views/Register.vue') diff --git a/client/src/views/Register.vue b/client/src/views/Register.vue index e26c751..238b5df 100644 --- a/client/src/views/Register.vue +++ b/client/src/views/Register.vue @@ -58,7 +58,7 @@ - +

@@ -87,7 +87,8 @@ export default { passwordConfirmBlured:false, showModal: false, modalTitle: '', - modalText: '' + modalText: '', + closeBtnAction: null } }, methods: { @@ -114,15 +115,36 @@ export default { submit() { this.validate(); - if (this.valid) { + + const successMsg = () => { this.modalTitle = 'Success!'; this.modalText = 'You successfully registered!'; this.showModal = true; - } - else { + this.closeBtnAction = () => this.$router.push('/'); + }; + + const failureMsg = () => { this.modalTitle = 'Failure!'; this.modalText = 'You failed to register.'; this.showModal = true; + this.closeBtnAction = () => this.showModal = false; + }; + + if (this.valid) { + const requestData = { + firstname: this.firstname, + lastname: this.lastname, + email: this.email, + password: this.password, + confirmPassword: this.passwordConfirm, + }; + + this.$store.dispatch('register', requestData) + .then(() => successMsg()) + .catch(() => failureMsg()); + } + else { + failureMsg(); } } } -- cgit v1.2.3