pleroma-fe/src/modules/oauth_tokens.js

27 lines
637 B
JavaScript
Raw Permalink Normal View History

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