pleroma-fe/src/stores/oauth_tokens.js
2025-05-10 22:35:15 -06:00

24 lines
No EOL
624 B
JavaScript

import { defineStore } from 'pinia'
export const useOAuthTokensStore = defineStore('oauthTokens', {
state: () => ({
tokens: []
}),
actions: {
fetchTokens () {
window.vuex.state.api.backendInteractor.fetchOAuthTokens().then((tokens) => {
this.swapTokens(tokens)
})
},
revokeToken (id) {
window.vuex.state.api.backendInteractor.revokeOAuthToken({ id }).then((response) => {
if (response.status === 201) {
this.swapTokens(this.tokens.filter(token => token.id !== id))
}
})
},
swapTokens (tokens) {
this.tokens = tokens
}
}
});