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">
|
<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.') }}
|
{{ t('libresign', 'This document has been certified with no changes allowed. You cannot add more signers to this document.') }}
|
||||||
</NcNoteCard>
|
</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()"
|
<NcButton v-if="filesStore.canAddSigner()"
|
||||||
:variant="hasSigners ? 'secondary' : 'primary'"
|
:variant="hasSigners ? 'secondary' : 'primary'"
|
||||||
@click="addSigner">
|
@click="addSigner">
|
||||||
|
|
@ -132,11 +135,7 @@
|
||||||
:size="size"
|
:size="size"
|
||||||
:name="modalTitle"
|
:name="modalTitle"
|
||||||
@closing="filesStore.disableIdentifySigner()">
|
@closing="filesStore.disableIdentifySigner()">
|
||||||
<NcNoteCard v-if="isSignerMethodDisabled" type="warning">
|
<NcAppSidebar :name="modalTitle"
|
||||||
{{ 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"
|
|
||||||
:active="activeTab"
|
:active="activeTab"
|
||||||
@update:active="onTabChange">
|
@update:active="onTabChange">
|
||||||
<NcAppSidebarTab v-for="method in enabledMethods"
|
<NcAppSidebarTab v-for="method in enabledMethods"
|
||||||
|
|
@ -150,7 +149,8 @@
|
||||||
<IdentifySigner :signer-to-edit="signerToEdit"
|
<IdentifySigner :signer-to-edit="signerToEdit"
|
||||||
:placeholder="method.friendly_name"
|
:placeholder="method.friendly_name"
|
||||||
:method="method.name"
|
:method="method.name"
|
||||||
:methods="methods" />
|
:methods="methods"
|
||||||
|
:disabled="isSignerMethodDisabled" />
|
||||||
</NcAppSidebarTab>
|
</NcAppSidebarTab>
|
||||||
</NcAppSidebar>
|
</NcAppSidebar>
|
||||||
</NcDialog>
|
</NcDialog>
|
||||||
|
|
@ -348,6 +348,10 @@ export default {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!this.canSignerActInOrder(signer)) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return !!method
|
return !!method
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
@ -377,6 +381,24 @@ export default {
|
||||||
return this.canSignerActInOrder(signer)
|
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() {
|
showSaveButton() {
|
||||||
if (!this.filesStore.canSave()) {
|
if (!this.filesStore.canSave()) {
|
||||||
return false
|
return false
|
||||||
|
|
@ -392,12 +414,19 @@ export default {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this.hasSignersWithDisabledMethods) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
return true
|
return true
|
||||||
},
|
},
|
||||||
showRequestButton() {
|
showRequestButton() {
|
||||||
if (!this.filesStore.canSave()) {
|
if (!this.filesStore.canSave()) {
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
if (this.hasSignersWithDisabledMethods) {
|
||||||
|
return false
|
||||||
|
}
|
||||||
return this.hasDraftSigners
|
return this.hasDraftSigners
|
||||||
},
|
},
|
||||||
hasDraftSigners() {
|
hasDraftSigners() {
|
||||||
|
|
@ -429,14 +458,16 @@ export default {
|
||||||
return this.t('libresign', 'Add new signer')
|
return this.t('libresign', 'Add new signer')
|
||||||
},
|
},
|
||||||
enabledMethods() {
|
enabledMethods() {
|
||||||
const enabledMethods = this.methods.filter(method => method.enabled)
|
|
||||||
|
|
||||||
if (Object.keys(this.signerToEdit).length > 0 && this.signerToEdit.identifyMethods?.length) {
|
if (Object.keys(this.signerToEdit).length > 0 && this.signerToEdit.identifyMethods?.length) {
|
||||||
const signerMethod = this.signerToEdit.identifyMethods[0].method
|
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() {
|
isSignerMethodDisabled() {
|
||||||
if (Object.keys(this.signerToEdit).length > 0 && this.signerToEdit.identifyMethods?.length) {
|
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
|
return iconMap[`svg${name.charAt(0).toUpperCase() + name.slice(1)}`] || iconMap.svgAccount
|
||||||
},
|
},
|
||||||
canSignerActInOrder(signer) {
|
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) {
|
if (!this.isOrderedNumeric) {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue