Client - revoke all token for a given client

This commit is contained in:
Sam
2022-06-12 18:03:26 +02:00
parent e01248d0d1
commit 524a221725
9 changed files with 94 additions and 9 deletions

View File

@ -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))
},
}

View File

@ -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',
}

View File

@ -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,
}

View File

@ -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
},
}

View File

@ -6,4 +6,5 @@ export const oAuth2State: IOAuth2State = {
client: <IOAuth2Client>{},
clients: [],
pagination: <IPagination>{},
revocationSuccessful: false,
}

View File

@ -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<