Migrate oauth tokens module to pinia store
This commit is contained in:
parent
6adfd81e71
commit
27f753e8de
7 changed files with 32 additions and 33 deletions
24
src/stores/oauth_tokens.js
Normal file
24
src/stores/oauth_tokens.js
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
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
|
||||
}
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue