Added info snackbars
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
import Vue from "vue";
|
||||
import Vuex from "vuex";
|
||||
|
||||
import snackbars from "./modules/snackbars";
|
||||
|
||||
import { getAuth, signInWithEmailAndPassword, signOut } from "firebase/auth";
|
||||
|
||||
Vue.use(Vuex);
|
||||
@@ -18,25 +20,26 @@ export default new Vuex.Store({
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
loginUser({ commit }, data) {
|
||||
loginUser({ commit, dispatch }, data) {
|
||||
const auth = getAuth();
|
||||
|
||||
signInWithEmailAndPassword(auth, data.email, data.pass)
|
||||
.then((userCredential) => {
|
||||
// Signed in
|
||||
commit("storeUser", userCredential.user);
|
||||
dispatch("infoMessage", "Zalogowano");
|
||||
// ...
|
||||
})
|
||||
.catch((error) => {
|
||||
const errorCode = error.code;
|
||||
const errorMessage = error.message;
|
||||
// const errorCode = error.code;
|
||||
// const errorMessage = error.message;
|
||||
});
|
||||
},
|
||||
logout({ commit }) {
|
||||
logout({ commit, dispatch }) {
|
||||
const auth = getAuth();
|
||||
signOut(auth)
|
||||
.then(() => {
|
||||
// Sign-out successful.
|
||||
dispatch("infoMessage", "Wylogowano");
|
||||
})
|
||||
.catch((error) => {
|
||||
// An error happened.
|
||||
@@ -48,5 +51,7 @@ export default new Vuex.Store({
|
||||
auth: (state) => state.user !== undefined,
|
||||
user: (state) => state.user,
|
||||
},
|
||||
modules: {},
|
||||
modules: {
|
||||
snackbars,
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user