pleroma-fe/src/stores/oauth_tokens.js

28 lines
674 B
JavaScript
Raw Normal View History

import { defineStore } from 'pinia'
export const useOAuthTokensStore = defineStore('oauthTokens', {
state: () => ({
2026-01-06 16:22:52 +02:00
tokens: [],
}),
actions: {
2026-01-06 16:22:52 +02:00
fetchTokens() {
window.vuex.state.api.backendInteractor
.fetchOAuthTokens()
.then((tokens) => {
this.swapTokens(tokens)
})
},
2026-01-06 16:22:52 +02:00
revokeToken(id) {
window.vuex.state.api.backendInteractor
.revokeOAuthToken({ id })
.then((response) => {
if (response.status === 201) {
this.swapTokens(this.tokens.filter((token) => token.id !== id))
}
})
},
2026-01-06 16:22:52 +02:00
swapTokens(tokens) {
this.tokens = tokens
2026-01-06 16:22:52 +02:00
},
},
})