18.05 Login User

This commit is contained in:
Fredrick W. Warren 2021-02-13 12:00:48 -08:00
parent abe5306e9c
commit b6d9272317
2 changed files with 13 additions and 3 deletions

View File

@ -65,8 +65,9 @@ export default {
}, },
methods: { methods: {
...mapActions('auth', [ ...mapActions('auth', [
'registerUser'] 'registerUser',
), 'loginUser'
]),
isValidEmailAddress (email) { isValidEmailAddress (email) {
const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/ const re = /^(([^<>()[\]\\.,;:\s@"]+(\.[^<>()[\]\\.,;:\s@"]+)*)|(".+"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/
return re.test(String(email).toLowerCase()) return re.test(String(email).toLowerCase())
@ -78,7 +79,7 @@ export default {
this.$refs.password.validate() this.$refs.password.validate()
if (!this.$refs.email.hasError && !this.$refs.password.hasError) { if (!this.$refs.email.hasError && !this.$refs.password.hasError) {
if (this.tab === 'login') { if (this.tab === 'login') {
console.log('login') this.loginUser(this.formData)
} else { } else {
this.registerUser(this.formData) this.registerUser(this.formData)
} }

View File

@ -15,6 +15,15 @@ const actions = {
.catch(error => { .catch(error => {
console.log('error.message: ', error) console.log('error.message: ', error)
}) })
},
loginUser ({ state }, payload) {
firebaseAuth.signInWithEmailAndPassword(payload.email, payload.password)
.then(response => {
console.log('response: ', response)
})
.catch(error => {
console.log('error.message: ', error)
})
} }
} }