Added firebase login
This commit is contained in:
@@ -1,16 +1,40 @@
|
||||
import Vue from "vue";
|
||||
import Vuex from "vuex";
|
||||
import axios from "axios";
|
||||
|
||||
Vue.use(Vuex);
|
||||
|
||||
export default new Vuex.Store({
|
||||
state: {
|
||||
token: "yes",
|
||||
user: undefined,
|
||||
},
|
||||
mutations: {
|
||||
storeUser(state, payload) {
|
||||
state.user = payload;
|
||||
},
|
||||
cleanUserData(state) {
|
||||
state.user = undefined;
|
||||
},
|
||||
},
|
||||
actions: {
|
||||
loginUser({ commit }, auth) {
|
||||
axios.post(
|
||||
"https://identitytoolkit.googleapis.com/v1/accounts:signInWithPassword?key=" + process.env.VUE_APP_FIREBASE_API_KEY,
|
||||
{
|
||||
email: auth.email,
|
||||
password: auth.pass,
|
||||
returnSecureToken: true,
|
||||
}
|
||||
).then((res) => {
|
||||
console.log(res);
|
||||
commit('storeUser', res.data);
|
||||
}).catch((e) => {
|
||||
console.error(e);
|
||||
})
|
||||
},
|
||||
},
|
||||
mutations: {},
|
||||
actions: {},
|
||||
getters: {
|
||||
auth: (state) => state.token !== undefined,
|
||||
auth: (state) => state.user !== undefined,
|
||||
},
|
||||
modules: {},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user