Controllers
This commit is contained in:
46
KTUSAPS/ClientApp/src/store/modules/msalAuth.js
Normal file
46
KTUSAPS/ClientApp/src/store/modules/msalAuth.js
Normal 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,
|
||||
}
|
Reference in New Issue
Block a user