From 319dd896f3a44237e1c26f3887fcb259f80f2714 Mon Sep 17 00:00:00 2001 From: jdlugosz963 Date: Thu, 11 Nov 2021 23:10:03 +0100 Subject: clean code and add notifications --- src/views/Register.vue | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) (limited to 'src/views/Register.vue') diff --git a/src/views/Register.vue b/src/views/Register.vue index c03f5fd..eb382c5 100644 --- a/src/views/Register.vue +++ b/src/views/Register.vue @@ -7,9 +7,8 @@ -

{{mess}}

- Already have account? + Already have an account? @@ -23,7 +22,6 @@ export default { login: "", password: "", repeat_password: "", - messages: [] } }, methods: { @@ -32,27 +30,28 @@ export default { e.preventDefault() if(this.password !== this.repeat_password){ - this.messages.push("Passwords not equals") + this.$notify({ + type: 'warn', + text: 'Passwords not equals', + }) this.password = "" this.repeat_password = "" return null } - const data = { + const register_data = { "username": this.login, "password": this.password } - try { - await AuthService.register(data) - this.messages.push("Success!") - }catch (error) { - if(error.response.data.username) - this.messages.push(error.response.data.username[0]) - if (error.response.data.password) - this.messages.push(error.response.data.password[0]) - + const { status } = await AuthService.register(register_data) + if (status === 200) { + this.$notify({ + type: 'success', + text:'Register success, you can now login.!' + }) + this.$router.push('/login') } } }, -- cgit v1.2.3