This repository has been archived on 2025-08-13. You can view files and clone it, but cannot push or open issues or pull requests.
Files
KTUSA-PS/KTUSAPS/ClientApp/src/store/modules/msalAuth.js
Karolis Kundrotas ba413d4330 Controllers
2021-10-29 09:17:17 +03:00

47 lines
910 B
JavaScript

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,
}