Skip to content

🔥 The free & Open Source DocuSign alternative

fix: integrate validation for the signature widget as mandatory using API

RaktimaNXG660eaeb714db
diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js
index 9b5c9e8fa..0666ebe64 100644
--- a/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js
+++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/CreateDocumentWithTemplate.js
@@ -88,6 +88,24 @@ export default async function createDocumentWithTemplate(request, response) {
const updateSigners = placeholder.every(y => signers?.some(x => x.role === y.Role));
// console.log('isValid ', isValid);
if (isValid && updateSigners) {
+ let isSignExist = false; // variable is used to check a signature widget exit or not then execute other code
+ //for loop is used to check signature widget exist or not
+ parent: for (let item of template?.Placeholders) {
+ // Reset for each iteration
+ for (let x of item?.placeHolder) {
+ if (!isSignExist) {
+ isSignExist = x.pos.some(data => data?.type === 'signature');
+ if (isSignExist) {
+ break parent;
+ }
+ }
+ }
+ }
+ if (!isSignExist) {
+ return response
+ .status(400)
+ .json({ error: 'Please add at least one signature widget for all signers' });
+ }
const folderPtr = {
__type: 'Pointer',
className: 'contracts_Document',
@@ -169,7 +187,7 @@ export default async function createDocumentWithTemplate(request, response) {
object.set('Signers', templateSigner);
}
object.set('URL', template.URL);
- object.set('SignedUrl', template.URL);
+ object.set('SignedUrl', template.URL);
object.set('CreatedBy', template.CreatedBy);
object.set('ExtUserPtr', {
__type: 'Pointer',
diff --git a/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js b/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js
index da93d48b6..e1d381d38 100644
--- a/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js
+++ b/apps/OpenSignServer/cloud/customRoute/v1/routes/createDocumentwithCoordinate.js
@@ -88,6 +88,18 @@ export default async function createDocumentwithCoordinate(request, response) {
objectId: parseUser.userId.objectId,
};
if (signers && signers.length > 0) {
+ //for loop is used to check signature widget exist or not
+ let isSignExist = true; // Reset for each iteration
+ for (let item of signers) {
+ if (!isSignExist) {
+ signatureExist = item.widgets.some(data => data?.type === 'signature');
+ }
+ }
+ if (!isSignExist) {
+ return response
+ .status(400)
+ .json({ error: 'Please add at least one signature widget for all signers' });
+ }
let fileUrl;
if (request.files?.[0]) {
const base64 = fileData?.toString('base64');