mirror of
https://github.com/LibreSign/libresign.git
synced 2025-12-17 21:12:16 +01:00
feat: prevent actions when identification methods are disabled
Add comprehensive validation for disabled identification methods: - Check method status in canSignerActInOrder to centralize validation - Hide menu actions (customize message, request signature, send reminder) for signers with disabled methods - Add hasSignersWithDisabledMethods computed property - Hide "Setup signature positions" and "Request signatures" buttons when any signer has a disabled method - Show warning message when disabled methods are detected - Always show signer's method in edit dialog even if disabled - Pass disabled prop to IdentifySigner component This ensures users cannot proceed with signature requests until all signers have valid identification methods. Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
This commit is contained in:
parent
ef393ca075
commit
4e34ff07ca
1 changed files with 49 additions and 10 deletions
|
|
@ -7,6 +7,9 @@
|
|||
<NcNoteCard v-if="showDocMdpWarning" type="warning">
|
||||
{{ t('libresign', 'This document has been certified with no changes allowed. You cannot add more signers to this document.') }}
|
||||
</NcNoteCard>
|
||||
<NcNoteCard v-if="hasSignersWithDisabledMethods" type="warning">
|
||||
{{ t('libresign', 'Some signers use identification methods that have been disabled. Please remove or update them before requesting signatures.') }}
|
||||
</NcNoteCard>
|
||||
<NcButton v-if="filesStore.canAddSigner()"
|
||||
:variant="hasSigners ? 'secondary' : 'primary'"
|
||||
@click="addSigner">
|
||||
|
|
@ -132,11 +135,7 @@
|
|||
:size="size"
|
||||
:name="modalTitle"
|
||||
@closing="filesStore.disableIdentifySigner()">
|
||||
<NcNoteCard v-if="isSignerMethodDisabled" type="warning">
|
||||
{{ t('libresign', 'The identification method "{method}" used by this signer has been disabled by the system administrator.', { method: disabledMethodName }) }}
|
||||
</NcNoteCard>
|
||||
<NcAppSidebar v-else
|
||||
:name="modalTitle"
|
||||
<NcAppSidebar :name="modalTitle"
|
||||
:active="activeTab"
|
||||
@update:active="onTabChange">
|
||||
<NcAppSidebarTab v-for="method in enabledMethods"
|
||||
|
|
@ -150,7 +149,8 @@
|
|||
<IdentifySigner :signer-to-edit="signerToEdit"
|
||||
:placeholder="method.friendly_name"
|
||||
:method="method.name"
|
||||
:methods="methods" />
|
||||
:methods="methods"
|
||||
:disabled="isSignerMethodDisabled" />
|
||||
</NcAppSidebarTab>
|
||||
</NcAppSidebar>
|
||||
</NcDialog>
|
||||
|
|
@ -348,6 +348,10 @@ export default {
|
|||
return false
|
||||
}
|
||||
|
||||
if (!this.canSignerActInOrder(signer)) {
|
||||
return false
|
||||
}
|
||||
|
||||
return !!method
|
||||
}
|
||||
},
|
||||
|
|
@ -377,6 +381,24 @@ export default {
|
|||
return this.canSignerActInOrder(signer)
|
||||
}
|
||||
},
|
||||
hasSignersWithDisabledMethods() {
|
||||
const file = this.filesStore.getFile()
|
||||
if (!file?.signers) {
|
||||
return false
|
||||
}
|
||||
|
||||
return file.signers.some(signer => {
|
||||
if (signer.signed) {
|
||||
return false
|
||||
}
|
||||
const method = signer.identifyMethods?.[0]?.method
|
||||
if (!method) {
|
||||
return false
|
||||
}
|
||||
const methodConfig = this.methods.find(m => m.name === method)
|
||||
return !methodConfig?.enabled
|
||||
})
|
||||
},
|
||||
showSaveButton() {
|
||||
if (!this.filesStore.canSave()) {
|
||||
return false
|
||||
|
|
@ -392,12 +414,19 @@ export default {
|
|||
return false
|
||||
}
|
||||
|
||||
if (this.hasSignersWithDisabledMethods) {
|
||||
return false
|
||||
}
|
||||
|
||||
return true
|
||||
},
|
||||
showRequestButton() {
|
||||
if (!this.filesStore.canSave()) {
|
||||
return false
|
||||
}
|
||||
if (this.hasSignersWithDisabledMethods) {
|
||||
return false
|
||||
}
|
||||
return this.hasDraftSigners
|
||||
},
|
||||
hasDraftSigners() {
|
||||
|
|
@ -429,14 +458,16 @@ export default {
|
|||
return this.t('libresign', 'Add new signer')
|
||||
},
|
||||
enabledMethods() {
|
||||
const enabledMethods = this.methods.filter(method => method.enabled)
|
||||
|
||||
if (Object.keys(this.signerToEdit).length > 0 && this.signerToEdit.identifyMethods?.length) {
|
||||
const signerMethod = this.signerToEdit.identifyMethods[0].method
|
||||
return enabledMethods.filter(method => method.name === signerMethod)
|
||||
const signerMethodConfig = this.methods.find(m => m.name === signerMethod)
|
||||
|
||||
if (signerMethodConfig) {
|
||||
return [signerMethodConfig]
|
||||
}
|
||||
}
|
||||
|
||||
return enabledMethods
|
||||
return this.methods.filter(method => method.enabled)
|
||||
},
|
||||
isSignerMethodDisabled() {
|
||||
if (Object.keys(this.signerToEdit).length > 0 && this.signerToEdit.identifyMethods?.length) {
|
||||
|
|
@ -494,6 +525,14 @@ export default {
|
|||
return iconMap[`svg${name.charAt(0).toUpperCase() + name.slice(1)}`] || iconMap.svgAccount
|
||||
},
|
||||
canSignerActInOrder(signer) {
|
||||
const method = signer.identifyMethods?.[0]?.method
|
||||
if (method) {
|
||||
const methodConfig = this.methods.find(m => m.name === method)
|
||||
if (!methodConfig?.enabled) {
|
||||
return false
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.isOrderedNumeric) {
|
||||
return true
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue