Skip to content
Permalink
fdceacf750
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
Latest commit fdceacf Apr 6, 2020 History
1 contributor

Users who have contributed to this file

46 lines (41 sloc) 920 Bytes
import Vue from 'vue'
import Vuex from 'vuex'
import { ui } from '@/plugins/firebaseui-init'
import { firebase } from '@/plugins/firebase-init'
Vue.use(Vuex)
const defaultState = {
user: {
uid: null,
displayName: null,
photoURL: null,
email: null,
phoneNumber: null,
}
};
const store = new Vuex.Store({
state: defaultState,
getters: {
isAuthenticated: state => {
return state.user.uid !== null;
}
},
mutations: {
user(state, userObj){
state.user = {
uid: userObj.uid,
displayName: userObj.displayName,
photoURL: userObj.photoURL,
email: userObj.email,
phoneNumber: userObj.email,
}
}
},
actions: {
signOut: async ( { dispatch, commit } ) => {
await firebase.auth().signOut();
commit('user', defaultState);
window.location.reload();
}
}
})
export default store;