Skip to content

Commit b7d6e9f

Browse files
committed
set sign in and sign up
1 parent 9bab001 commit b7d6e9f

File tree

2 files changed

+52
-4
lines changed

2 files changed

+52
-4
lines changed

src/components/User/Signin.vue

Lines changed: 27 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template>
22
<v-container>
3-
3+
<v-layout row v-if="error">
4+
<v-flex xs12 sm6 offset-sm3>
5+
<app-alert @dismissed="onDismissed" :text="error.message"></app-alert>
6+
</v-flex>
7+
</v-layout>
48
<v-layout row>
59
<v-flex xs12 sm6 offset-sm3>
610
<v-card>
@@ -56,9 +60,30 @@
5660
password: ''
5761
}
5862
},
63+
computed: {
64+
user () {
65+
return this.$store.getters.user
66+
},
67+
error () {
68+
return this.$store.getters.error
69+
},
70+
loading () {
71+
return this.$store.getters.loading
72+
}
73+
},
74+
watch: {
75+
user (value) {
76+
if (value !== null && value !== undefined) {
77+
this.$router.push('/')
78+
}
79+
}
80+
},
5981
methods: {
6082
onSignin () {
61-
//
83+
this.$store.dispatch('signUserIn', {email: this.email, password: this.password})
84+
},
85+
onDismissed () {
86+
this.$store.dispatch('clearError')
6287
}
6388
}
6489
}

src/components/User/Signup.vue

Lines changed: 25 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,10 @@
11
<template>
22
<v-container>
3-
3+
<v-layout row v-if="error">
4+
<v-flex xs12 sm6 offset-sm3>
5+
<app-alert @dismissed="onDismissed" :text="error.message"></app-alert>
6+
</v-flex>
7+
</v-layout>
48
<v-layout row>
59
<v-flex xs12 sm6 offset-sm3>
610
<v-card>
@@ -71,11 +75,30 @@
7175
computed: {
7276
comparePasswords () {
7377
return this.password !== this.confirmPassword ? 'Passwords do not match' : ''
78+
},
79+
user () {
80+
return this.$store.getters.user
81+
},
82+
error () {
83+
return this.$store.getters.error
84+
},
85+
loading () {
86+
return this.$store.getters.loading
87+
}
88+
},
89+
watch: {
90+
user (value) {
91+
if (value !== null && value !== undefined) {
92+
this.$router.push('/')
93+
}
7494
}
7595
},
7696
methods: {
7797
onSignup () {
78-
//
98+
this.$store.dispatch('signUserUp', {email: this.email, password: this.password})
99+
},
100+
onDismissed () {
101+
this.$store.dispatch('clearError')
79102
}
80103
}
81104
}

0 commit comments

Comments
 (0)