2019-02-13 05:53:59 +11:00
|
|
|
const oauthTokens = {
|
|
|
|
state: {
|
|
|
|
tokens: []
|
|
|
|
},
|
|
|
|
actions: {
|
2019-07-05 17:02:14 +10:00
|
|
|
fetchTokens ({ rootState, commit }) {
|
2019-02-13 05:53:59 +11:00
|
|
|
rootState.api.backendInteractor.fetchOAuthTokens().then((tokens) => {
|
|
|
|
commit('swapTokens', tokens)
|
|
|
|
})
|
|
|
|
},
|
2019-07-05 17:02:14 +10:00
|
|
|
revokeToken ({ rootState, commit, state }, id) {
|
2019-11-24 22:57:46 +11:00
|
|
|
rootState.api.backendInteractor.revokeOAuthToken({ id }).then((response) => {
|
2019-02-13 05:53:59 +11:00
|
|
|
if (response.status === 201) {
|
|
|
|
commit('swapTokens', state.tokens.filter(token => token.id !== id))
|
|
|
|
}
|
|
|
|
})
|
|
|
|
}
|
|
|
|
},
|
|
|
|
mutations: {
|
|
|
|
swapTokens (state, tokens) {
|
|
|
|
state.tokens = tokens
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
export default oauthTokens
|