Skip to content

Instantly share code, notes, and snippets.

@opichon
Created June 30, 2017 15:00
Show Gist options
  • Save opichon/f763bb6c38c6cd83eceed70d30a003f5 to your computer and use it in GitHub Desktop.
Save opichon/f763bb6c38c6cd83eceed70d30a003f5 to your computer and use it in GitHub Desktop.
vue.js/electron demo
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