18.04 Register User

This commit is contained in:
Fredrick W. Warren 2021-02-12 22:22:00 -08:00
parent 6ec3e3ad11
commit abe5306e9c
3 changed files with 26 additions and 11 deletions

View File

@ -1,18 +1,18 @@
import firebase from "firebase/app"
import firebase from 'firebase/app'
import "firebase/auth"
import 'firebase/auth'
var firebaseConfig = {
apiKey: "AIzaSyD1xL6X7oCD3IQC_F7vv-mYT4k1Ud0j7qs",
authDomain: "awesometodo-c0aa0.firebaseapp.com",
databaseURL: "https://awesometodo-c0aa0-default-rtdb.firebaseio.com",
projectId: "awesometodo-c0aa0",
storageBucket: "awesometodo-c0aa0.appspot.com",
messagingSenderId: "959628658138",
appId: "1:959628658138:web:37d05be55e433b6e54ece3"
apiKey: 'AIzaSyD1xL6X7oCD3IQC_F7vv-mYT4k1Ud0j7qs',
authDomain: 'awesometodo-c0aa0.firebaseapp.com',
databaseURL: 'https://awesometodo-c0aa0-default-rtdb.firebaseio.com',
projectId: 'awesometodo-c0aa0',
storageBucket: 'awesometodo-c0aa0.appspot.com',
messagingSenderId: '959628658138',
appId: '1:959628658138:web:37d05be55e433b6e54ece3'
}
const firebaseApp = firebase.initializeApp(firebaseConfig)
const firebaseAuth = firebaseApp.auth()
export { firebaseAuth }
export { firebaseAuth }

View File

@ -45,6 +45,7 @@
</template>
<script>
import { mapActions } from 'vuex'
export default {
props: [
'tab'
@ -63,6 +64,9 @@ export default {
}
},
methods: {
...mapActions('auth', [
'registerUser']
),
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,}))$/
return re.test(String(email).toLowerCase())
@ -76,7 +80,7 @@ export default {
if (this.tab === 'login') {
console.log('login')
} else {
console.log('register')
this.registerUser(this.formData)
}
}
}

View File

@ -1,3 +1,5 @@
import { firebaseAuth } from 'boot/firebase'
const state = {
}
@ -5,6 +7,15 @@ const mutations = {
}
const actions = {
registerUser ({ state }, payload) {
firebaseAuth.createUserWithEmailAndPassword(payload.email, payload.password)
.then(response => {
console.log('response: ', response)
})
.catch(error => {
console.log('error.message: ', error)
})
}
}
const getters = {