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
|
|
@ -7,7 +7,6 @@ import config from './config.js'
|
|||
import profileConfig from './profileConfig.js'
|
||||
import adminSettings from './adminSettings.js'
|
||||
import authFlow from './auth_flow.js'
|
||||
import oauthTokens from './oauth_tokens.js'
|
||||
import drafts from './drafts.js'
|
||||
import chats from './chats.js'
|
||||
|
||||
|
|
@ -21,7 +20,6 @@ export default {
|
|||
profileConfig,
|
||||
adminSettings,
|
||||
authFlow,
|
||||
oauthTokens,
|
||||
drafts,
|
||||
chats
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,26 +0,0 @@
|
|||
const oauthTokens = {
|
||||
state: {
|
||||
tokens: []
|
||||
},
|
||||
actions: {
|
||||
fetchTokens ({ rootState, commit }) {
|
||||
rootState.api.backendInteractor.fetchOAuthTokens().then((tokens) => {
|
||||
commit('swapTokens', tokens)
|
||||
})
|
||||
},
|
||||
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
|
||||
Loading…
Add table
Add a link
Reference in a new issue