Client - revoke all token for a given client
This commit is contained in:
@ -3,13 +3,22 @@
|
||||
<Modal
|
||||
v-if="displayModal"
|
||||
:title="$t('common.CONFIRMATION')"
|
||||
:message="$t('oauth2.APP_DELETION_CONFIRMATION')"
|
||||
@confirmAction="deleteClient(client.id)"
|
||||
:message="$t(messageToDisplay)"
|
||||
@confirmAction="confirmAction(client.id)"
|
||||
@cancelAction="updateDisplayModal(false)"
|
||||
/>
|
||||
<div v-if="client && client.client_id">
|
||||
<div class="info-box success-message" v-if="afterCreation">
|
||||
{{ $t('oauth2.APP_CREATED_SUCCESSFULLY') }}
|
||||
<div
|
||||
class="info-box success-message"
|
||||
v-if="afterCreation || revocationSuccessful"
|
||||
>
|
||||
{{
|
||||
$t(
|
||||
afterCreation
|
||||
? 'oauth2.APP_CREATED_SUCCESSFULLY'
|
||||
: 'oauth2.TOKENS_REVOKED'
|
||||
)
|
||||
}}
|
||||
</div>
|
||||
<dl>
|
||||
<dt>{{ $t('oauth2.APP.CLIENT_ID') }}:</dt>
|
||||
@ -55,7 +64,10 @@
|
||||
</dd>
|
||||
</dl>
|
||||
<div class="app-buttons">
|
||||
<button class="danger" @click="updateDisplayModal(true)">
|
||||
<button class="danger" @click="updateMessageToDisplay(false)">
|
||||
{{ $t('oauth2.REVOKE_ALL_TOKENS') }}
|
||||
</button>
|
||||
<button class="danger" @click="updateMessageToDisplay(true)">
|
||||
{{ $t('oauth2.DELETE_APP') }}
|
||||
</button>
|
||||
<button @click="$router.push('/profile/apps')">
|
||||
@ -84,6 +96,7 @@
|
||||
ref,
|
||||
onUnmounted,
|
||||
withDefaults,
|
||||
watch,
|
||||
} from 'vue'
|
||||
import { useRoute } from 'vue-router'
|
||||
|
||||
@ -107,7 +120,11 @@
|
||||
const client: ComputedRef<IOAuth2Client> = computed(
|
||||
() => store.getters[OAUTH2_STORE.GETTERS.CLIENT]
|
||||
)
|
||||
const revocationSuccessful: ComputedRef<boolean> = computed(
|
||||
() => store.getters[OAUTH2_STORE.GETTERS.REVOCATION_SUCCESSFUL]
|
||||
)
|
||||
let displayModal: Ref<boolean> = ref(false)
|
||||
let messageToDisplay: Ref<string | null> = ref(null)
|
||||
|
||||
onBeforeMount(() => {
|
||||
loadClient()
|
||||
@ -123,16 +140,39 @@
|
||||
store.dispatch(OAUTH2_STORE.ACTIONS.GET_CLIENT_BY_ID, +route.params.id)
|
||||
}
|
||||
}
|
||||
function deleteClient(clientId: number) {
|
||||
store.dispatch(OAUTH2_STORE.ACTIONS.DELETE_CLIENT, clientId)
|
||||
function updateMessageToDisplay(forDelete: boolean) {
|
||||
messageToDisplay.value = forDelete
|
||||
? 'oauth2.APP_DELETION_CONFIRMATION'
|
||||
: 'oauth2.TOKENS_REVOCATION_CONFIRMATION'
|
||||
updateDisplayModal(true)
|
||||
}
|
||||
function updateDisplayModal(value: boolean) {
|
||||
displayModal.value = value
|
||||
if (!value) {
|
||||
messageToDisplay.value = null
|
||||
}
|
||||
}
|
||||
function confirmAction(clientId: number) {
|
||||
if (messageToDisplay.value === 'oauth2.APP_DELETION_CONFIRMATION') {
|
||||
store.dispatch(OAUTH2_STORE.ACTIONS.DELETE_CLIENT, clientId)
|
||||
} else {
|
||||
store.dispatch(OAUTH2_STORE.ACTIONS.REVOKE_ALL_TOKENS, clientId)
|
||||
}
|
||||
}
|
||||
onUnmounted(() => {
|
||||
store.commit(ROOT_STORE.MUTATIONS.EMPTY_ERROR_MESSAGES)
|
||||
store.commit(OAUTH2_STORE.MUTATIONS.EMPTY_CLIENT)
|
||||
store.commit(OAUTH2_STORE.MUTATIONS.SET_REVOCATION_SUCCESSFUL, false)
|
||||
})
|
||||
|
||||
watch(
|
||||
() => revocationSuccessful.value,
|
||||
(newValue) => {
|
||||
if (newValue) {
|
||||
updateDisplayModal(false)
|
||||
}
|
||||
}
|
||||
)
|
||||
</script>
|
||||
|
||||
<style scoped lang="scss">
|
||||
|
Reference in New Issue
Block a user