Controllers

This commit is contained in:
Karolis Kundrotas
2021-10-29 09:17:17 +03:00
parent aff6f8df82
commit ba413d4330
22 changed files with 675 additions and 292 deletions

View File

@@ -0,0 +1,46 @@
import { WatchMsalState, GetMsalState } from '@/msal'
// initial state
const state = () => ({
isLoggedIn: false,
accessToken: null,
idToken: null,
email: null,
displayName: null,
debugFullTokenResponse: null,
debugAccountInfo: null,
})
// getters
const getters = {}
// actions
const actions = {
initialize({ commit }) {
WatchMsalState(() => {
commit('setState', GetMsalState())
})
},
}
// mutations
const mutations = {
setState(state, msalState) {
state.isLoggedIn = msalState.isLoggedIn
state.accessToken = msalState.accessToken
state.idToken = msalState.idToken
state.debugFullTokenResponse = msalState.debugFullTokenResponse
state.debugAccountInfo = msalState.debugAccountInfo
state.email = msalState.email
state.displayName = msalState.displayName
},
}
export default {
namespaced: true,
state,
getters,
actions,
mutations,
}