Improve login/logout
Extract mutation types to mutation-types.js
This commit is contained in:
@ -1,6 +1,7 @@
|
||||
import { createStore } from 'vuex'
|
||||
import dashboard from './dashboard/index'
|
||||
import budget from './budget/index'
|
||||
import { LOGIN_SUCCESS, LOGOUT } from './mutation-types'
|
||||
|
||||
const store = createStore({
|
||||
state () {
|
||||
@ -23,13 +24,11 @@ const store = createStore({
|
||||
setTitle (state, title) {
|
||||
document.title = "Budgeteer - " + title;
|
||||
},
|
||||
setToken(state, token) {
|
||||
state.Session.Token = token;
|
||||
}
|
||||
},
|
||||
actions: {
|
||||
logout({state, commit, rootState}){
|
||||
commit("setToken", null);
|
||||
[LOGIN_SUCCESS](state, session) {
|
||||
state.Session = session;
|
||||
},
|
||||
[LOGOUT](state, token) {
|
||||
state.Session = { Token: null, User: null }
|
||||
}
|
||||
},
|
||||
modules: {
|
||||
|
Reference in New Issue
Block a user