+Vuex +ElementUI +Pug

- Log on now works, storing user profile in vuex state
- Templates in Pug = awesome
This commit is contained in:
Daniel J. Summers
2017-08-05 22:48:09 -05:00
parent 338f11d1ab
commit 196db30cc5
13 changed files with 506 additions and 122 deletions

View File

@@ -0,0 +1,31 @@
import Vue from 'vue'
import Vuex from 'vuex'
import AuthService from '@/auth/AuthService'
import * as types from './mutation-types'
Vue.use(Vuex)
this.auth0 = new AuthService()
export default new Vuex.Store({
state: {
user: JSON.parse(localStorage.getItem('user_profile') || '{}'),
isAuthenticated: this.auth0.isAuthenticated()
},
mutations: {
[types.USER_LOGGED_ON] (state, user) {
localStorage.setItem('user_profile', JSON.stringify(user))
state.user = user
state.isAuthenticated = true
},
[types.USER_LOGGED_OFF] (state) {
state.user = {}
state.isAuthenticated = false
}
},
actions: {},
getters: {},
modules: {}
})

View File

@@ -0,0 +1,2 @@
export const USER_LOGGED_OFF = 'user-logged-out'
export const USER_LOGGED_ON = 'user-logged-on'