Improve login/logout
Extract mutation types to mutation-types.js
This commit is contained in:
1 parent
6dcf7da861
commit
74c4c7cb02
5 files changed
+35
-15
No files matched your search
@@ -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