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/Login.vue | 25 +++++++++++++------------ 1 file changed, 13 insertions(+), 12 deletions(-) (limited to 'src/views/Login.vue') diff --git a/src/views/Login.vue b/src/views/Login.vue index ae43ecd..cb5c8d8 100644 --- a/src/views/Login.vue +++ b/src/views/Login.vue @@ -6,9 +6,8 @@ -

{{mess}}

- Still don't have account? + Still don't have an account? @@ -21,25 +20,27 @@ export default { return { login: "", password: "", - messages: [] } }, methods: { async log_in(e) { e.preventDefault() - const data = { + const login_data = { "username": this.login, "password": this.password } - try{ - const res = await AuthService.login(data) - this.$store.dispatch('login', {token: res.token, user: res.user}) - this.$router.push('/') - } catch (error) { - console.log(error.response.data) - this.messages.push('Wrong username or password!') - } + + const {data, status} = await AuthService.login(login_data) + + if (status === 200) { + this.$store.dispatch('login', {token: data.token, user: data.user}) + this.$notify({ + type: 'success', + text: 'Success!' + }) + this.$router.push('/') + } } }, created() { -- cgit v1.2.3