Improve login/logout

Extract mutation types to mutation-types.js
This commit is contained in:
2022-01-25 20:30:47 +00:00
parent 6dcf7da861
commit 74c4c7cb02
5 changed files with 35 additions and 15 deletions

View File

@ -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: {