Created
June 30, 2017 15:00
-
-
Save opichon/f763bb6c38c6cd83eceed70d30a003f5 to your computer and use it in GitHub Desktop.
vue.js/electron demo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import Vue from 'vue' | |
import Vuex from 'vuex' | |
import VueAuthenticate from 'vue-authenticate' | |
Vue.use(Vuex) | |
const vueAuth = new VueAuthenticate(Vue.http, { | |
baseUrl: 'http://localhost:3000' | |
}) | |
export default new Vuex.Store({ | |
strict: process.env.NODE_ENV !== 'production', | |
state: { | |
isAuthenticated: false | |
}, | |
getters: { | |
isAuthenticated () { | |
return vueAuth.isAuthenticated() | |
} | |
}, | |
mutations: { | |
isAuthenticated (state, payload) { | |
state.isAuthenticated = payload.isAuthenticated | |
} | |
}, | |
actions: { | |
login (context, payload) { | |
vueAuth.login(payload.user, payload.requestOptions) | |
.then((response) => { | |
context.commit('isAuthenticated', { | |
isAuthenticated: vueAuth.isAuthenticated() | |
}) | |
}) | |
} | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment