diff --git a/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php b/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php index 07d9fee098..f6a950a2ed 100644 --- a/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php +++ b/lib/Service/IdentifyMethod/AbstractIdentifyMethod.php @@ -320,7 +320,9 @@ private function loadSavedSettings(): void { foreach ($this->availableSignatureMethods as $signatureMethodName) { $this->signatureMethods[$signatureMethodName] = $this->getEmptyInstanceOfSignatureMethodByName($signatureMethodName); - if (isset($this->settings[$signatureMethodName]['enabled']) && $this->settings[$signatureMethodName]['enabled']) { + if (isset($this->settings['signatureMethods'][$signatureMethodName]['enabled']) + && $this->settings['signatureMethods'][$signatureMethodName]['enabled'] + ) { $this->signatureMethods[$signatureMethodName]->enable(); $enabled = true; } diff --git a/src/views/SignPDF/_partials/ModalEmailManager.vue b/src/views/SignPDF/_partials/ModalEmailManager.vue index 7c39ad2e83..cd50b9be92 100644 --- a/src/views/SignPDF/_partials/ModalEmailManager.vue +++ b/src/views/SignPDF/_partials/ModalEmailManager.vue @@ -72,6 +72,7 @@ import md5 from 'blueimp-md5' import { onError } from '../../../helpers/errors.js' import { validateEmail } from '../../../utils/validators.js' import { useSignMethodsStore } from '../../../store/signMethods.js' +import { useSignStore } from '../../../store/sign.js' const sanitizeNumber = val => { val = val.replace(/\D/g, '') @@ -88,21 +89,10 @@ export default { EmailIcon, NcButton, }, - props: { - fileId: { - type: Number, - required: false, - default: 0, - }, - uuid: { - type: String, - required: false, - default: '', - }, - }, setup() { + const signStore = useSignStore() const signMethodsStore = useSignMethodsStore() - return { signMethodsStore } + return { signStore, signMethodsStore } }, data: () => ({ loading: false, @@ -153,9 +143,11 @@ export default { await this.$nextTick() try { - if (this.fileId.length > 0) { + if (this.signStore.document.fileId) { const { data } = await axios.post( - generateOcsUrl('/apps/libresign/api/v1/sign/file_id/{fileId}/code', { fileId: this.fileId }), + generateOcsUrl('/apps/libresign/api/v1/sign/file_id/{fileId}/code', { + fileId: this.signStore.document.fileId, + }), { identify: this.sendTo, identifyMethod: this.signMethodsStore.settings.emailToken.identifyMethod, @@ -164,8 +156,11 @@ export default { ) showSuccess(data.message) } else { + const signer = this.signStore.document.signers.find(row => row.me) || {} const { data } = await axios.post( - generateOcsUrl('/apps/libresign/api/v1/sign/uuid/{uuid}/code', { uuid: this.uuid }), + generateOcsUrl('/apps/libresign/api/v1/sign/uuid/{uuid}/code', { + uuid: signer.sign_uuid, + }), { identify: this.sendTo, identifyMethod: this.signMethodsStore.settings.emailToken.identifyMethod, diff --git a/src/views/SignPDF/_partials/ModalSMSManager.vue b/src/views/SignPDF/_partials/ModalSMSManager.vue index 48c1c1b7f4..74e994f539 100644 --- a/src/views/SignPDF/_partials/ModalSMSManager.vue +++ b/src/views/SignPDF/_partials/ModalSMSManager.vue @@ -55,6 +55,7 @@ import { confirmPassword } from '@nextcloud/password-confirmation' import { showError, showSuccess } from '@nextcloud/dialogs' import { onError } from '../../../helpers/errors.js' import { settingsService } from '../../../domains/settings/index.js' +import { useSignStore } from '../../../store/sign.js' const sanitizeNumber = val => { val = val.replace(/\D/g, '') @@ -74,16 +75,10 @@ export default { type: String, required: true, }, - fileId: { - type: Number, - required: false, - default: 0, - }, - uuid: { - type: String, - required: false, - default: '', - }, + }, + setup() { + const signStore = useSignStore() + return { signStore } }, data: () => ({ token: '', @@ -123,14 +118,15 @@ export default { await this.$nextTick() try { - if (this.fileId.length > 0) { + if (this.signStore.document.fileId) { const { data } = await axios.post(generateOcsUrl('/apps/libresign/api/v1/sign/file_id/{fileId}/code', { - fileId: this.fileId, + fileId: this.signStore.document.fileId, })) showSuccess(data.message) } else { + const signer = this.signStore.document.signers.find(row => row.me) || {} const { data } = await axios.post(generateOcsUrl('/apps/libresign/api/v1/sign/uuid/{fileId}/code', { - uuid: this.uuid, + uuid: signer.sign_uuid, })) showSuccess(data.message) } diff --git a/src/views/SignPDF/_partials/Sign.vue b/src/views/SignPDF/_partials/Sign.vue index a3c5853e14..06a1d6cd61 100644 --- a/src/views/SignPDF/_partials/Sign.vue +++ b/src/views/SignPDF/_partials/Sign.vue @@ -84,15 +84,11 @@ diff --git a/tests/integration/features/admin/initial_state.feature b/tests/integration/features/admin/initial_state.feature index 1d3d3365c6..70db1c0bde 100644 --- a/tests/integration/features/admin/initial_state.feature +++ b/tests/integration/features/admin/initial_state.feature @@ -70,12 +70,12 @@ Feature: admin/initial_state Scenario: Update identify methods and retrieve with success as initial state Given as user "admin" When sending "post" to ocs "/apps/provisioning_api/api/v1/config/apps/libresign/identify_methods" - | value | (string)[{"name":"account","enabled":true,"mandatory":true},{"name":"email","enabled":false,"mandatory":false}] | + | value | (string)[{"name":"account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":true}}},{"name":"email","enabled":false,"mandatory":false}] | Then sending "get" to "/settings/admin/libresign" And the response should contain the initial state "libresign-identify_methods" with the following values: """ [ - {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":true,"label":"Certificate with password","name":"password"}}}, + {"name":"account","friendly_name":"Account","enabled":true,"mandatory":true,"signatureMethods":{"clickToSign":{"enabled":true,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":false,"label":"Email token","name":"emailToken"},"password":{"enabled":false,"label":"Certificate with password","name":"password"}}}, {"name":"email","friendly_name":"Email","enabled":false,"mandatory":false,"can_create_account":true,"test_url":"/index.php/settings/admin/mailtest","signatureMethods":{"clickToSign":{"enabled":false,"label":"Click to sign","name":"clickToSign"},"emailToken":{"enabled":true,"label":"Email token","name":"emailToken"}}} ] """