Skip to content

Instantly share code, notes, and snippets.

@Serhansolo
Created April 14, 2020 12:24
Show Gist options
  • Save Serhansolo/c8991ed0a503afbb01da01ee2abea6f3 to your computer and use it in GitHub Desktop.
Save Serhansolo/c8991ed0a503afbb01da01ee2abea6f3 to your computer and use it in GitHub Desktop.
import firebase from "firebase/app";
const actions = {
signUpAction({ commit }, payload) {
firebase
.auth()
.createUserWithEmailAndPassword(payload.email, payload.password)
.then(response => {
commit("setUser", response.user);
})
.catch(error => {
commit("setError", error.message);
});
},
signInAction({ commit }, payload) {
firebase
.auth()
.signInWithEmailAndPassword(payload.email, payload.password)
.then(response => {
commit("setUser", response.user);
})
.catch(error => {
commit("setError", error.message);
});
},
signOutAction({ commit }) {
firebase
.auth()
.signOut()
.then(() => {
commit("setUser", null);
})
.catch(error => {
commit("setError", error.message);
});
}
};
export default actions;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment