Added info snackbars

This commit is contained in:
Kamil Klecha
2021-10-19 22:38:37 +02:00
parent 9dfa29081b
commit 1a56edde49
7 changed files with 110 additions and 6 deletions

View File

@@ -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,
},
});