Client - revoke all token for a given client
This commit is contained in:
@ -134,4 +134,21 @@ export const actions: ActionTree<IOAuth2State, IRootState> & IOAuth2Actions = {
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
[OAUTH2_STORE.ACTIONS.REVOKE_ALL_TOKENS](
|
||||
context: ActionContext<IOAuth2State, IRootState>,
|
||||
id: number
|
||||
): void {
|
||||
context.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
context.commit(OAUTH2_STORE.MUTATIONS.SET_REVOCATION_SUCCESSFUL, false)
|
||||
authApi
|
||||
.post(`oauth/apps/${id}/revoke`)
|
||||
.then((res) => {
|
||||
if (res.data.status === 'success') {
|
||||
context.commit(OAUTH2_STORE.MUTATIONS.SET_REVOCATION_SUCCESSFUL, true)
|
||||
} else {
|
||||
handleError(context, null)
|
||||
}
|
||||
})
|
||||
.catch((error) => handleError(context, error))
|
||||
},
|
||||
}
|
||||
|
@ -5,12 +5,14 @@ export enum OAuth2Actions {
|
||||
GET_CLIENTS = 'GET_CLIENTS',
|
||||
GET_CLIENT_BY_CLIENT_ID = 'GET_CLIENT_BY_CLIENT_ID',
|
||||
GET_CLIENT_BY_ID = 'GET_CLIENT_BY_ID',
|
||||
REVOKE_ALL_TOKENS = 'REVOKE_ALL_TOKENS',
|
||||
}
|
||||
|
||||
export enum OAuth2Getters {
|
||||
CLIENT = 'CLIENT',
|
||||
CLIENTS = 'CLIENTS',
|
||||
CLIENTS_PAGINATION = 'CLIENTS_PAGINATION',
|
||||
REVOCATION_SUCCESSFUL = 'REVOCATION_SUCCESSFUL',
|
||||
}
|
||||
|
||||
export enum OAuth2Mutations {
|
||||
@ -18,4 +20,5 @@ export enum OAuth2Mutations {
|
||||
SET_CLIENT = 'SET_CLIENT',
|
||||
SET_CLIENTS = 'SET_CLIENTS',
|
||||
SET_CLIENTS_PAGINATION = 'SET_CLIENTS_PAGINATION',
|
||||
SET_REVOCATION_SUCCESSFUL = 'SET_REVOCATION_SUCCESSFUL',
|
||||
}
|
||||
|
@ -9,4 +9,6 @@ export const getters: GetterTree<IOAuth2State, IRootState> & IOAuth2Getters = {
|
||||
[OAUTH2_STORE.GETTERS.CLIENTS]: (state: IOAuth2State) => state.clients,
|
||||
[OAUTH2_STORE.GETTERS.CLIENTS_PAGINATION]: (state: IOAuth2State) =>
|
||||
state.pagination,
|
||||
[OAUTH2_STORE.GETTERS.REVOCATION_SUCCESSFUL]: (state: IOAuth2State) =>
|
||||
state.revocationSuccessful,
|
||||
}
|
||||
|
@ -27,4 +27,10 @@ export const mutations: MutationTree<IOAuth2State> & TOAuth2Mutations = {
|
||||
) {
|
||||
state.pagination = pagination
|
||||
},
|
||||
[OAUTH2_STORE.MUTATIONS.SET_REVOCATION_SUCCESSFUL](
|
||||
state: IOAuth2State,
|
||||
revocationSuccessful: boolean
|
||||
) {
|
||||
state.revocationSuccessful = revocationSuccessful
|
||||
},
|
||||
}
|
||||
|
@ -6,4 +6,5 @@ export const oAuth2State: IOAuth2State = {
|
||||
client: <IOAuth2Client>{},
|
||||
clients: [],
|
||||
pagination: <IPagination>{},
|
||||
revocationSuccessful: false,
|
||||
}
|
||||
|
@ -19,6 +19,7 @@ export interface IOAuth2State {
|
||||
client: IOAuth2Client
|
||||
clients: IOAuth2Client[]
|
||||
pagination: IPagination
|
||||
revocationSuccessful: boolean
|
||||
}
|
||||
|
||||
export interface IOAuth2Actions {
|
||||
@ -46,12 +47,17 @@ export interface IOAuth2Actions {
|
||||
context: ActionContext<IOAuth2State, IRootState>,
|
||||
payload: IOauth2ClientsPayload
|
||||
): void
|
||||
[OAUTH2_STORE.ACTIONS.REVOKE_ALL_TOKENS](
|
||||
context: ActionContext<IOAuth2State, IRootState>,
|
||||
id: number
|
||||
): void
|
||||
}
|
||||
|
||||
export interface IOAuth2Getters {
|
||||
[OAUTH2_STORE.GETTERS.CLIENT](state: IOAuth2State): IOAuth2Client
|
||||
[OAUTH2_STORE.GETTERS.CLIENTS](state: IOAuth2State): IOAuth2Client[]
|
||||
[OAUTH2_STORE.GETTERS.CLIENTS_PAGINATION](state: IOAuth2State): IPagination
|
||||
[OAUTH2_STORE.GETTERS.REVOCATION_SUCCESSFUL](state: IOAuth2State): boolean
|
||||
}
|
||||
|
||||
export type TOAuth2Mutations<S = IOAuth2State> = {
|
||||
@ -62,6 +68,10 @@ export type TOAuth2Mutations<S = IOAuth2State> = {
|
||||
state: S,
|
||||
pagination: IPagination
|
||||
): void
|
||||
[OAUTH2_STORE.MUTATIONS.SET_REVOCATION_SUCCESSFUL](
|
||||
state: S,
|
||||
revocationSuccessful: boolean
|
||||
): void
|
||||
}
|
||||
|
||||
export type TOAuth2StoreModule<S = IOAuth2State> = Omit<
|
||||
|
Reference in New Issue
Block a user