mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
Fix 'something went wrong' error when non-existing signer attempts to sign the document
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -91,6 +91,7 @@ export default async function createDocumentWithTemplate(request, response) {
|
||||
if (totalcredits > 0) {
|
||||
const templateQuery = new Parse.Query('contracts_Template');
|
||||
templateQuery.include('ExtUserPtr');
|
||||
templateQuery.include('ExtUserPtr.TenantId');
|
||||
const templateRes = await templateQuery.get(templateId, { useMasterKey: true });
|
||||
if (templateRes) {
|
||||
const template = JSON.parse(JSON.stringify(templateRes));
|
||||
|
||||
@@ -35,6 +35,7 @@ export default async function deleteFolder(request, response) {
|
||||
folder.notEqualTo('IsArchive', true);
|
||||
folder.equalTo('CreatedBy', userPtr);
|
||||
folder.equalTo('Type', 'Folder');
|
||||
folder.include('ExtUserPtr.TenantId');
|
||||
const isSubItems = await folder.first({ useMasterKey: true });
|
||||
// console.log('isSubItems ', isSubItems);
|
||||
if (isSubItems) {
|
||||
|
||||
@@ -19,6 +19,7 @@ export default async function deletedTemplate(request, response) {
|
||||
const template = new Parse.Query('contracts_Template');
|
||||
template.equalTo('objectId', request.params.template_id);
|
||||
template.equalTo('CreatedBy', userPtr);
|
||||
template.include('ExtUserPtr.TenantId');
|
||||
const res = await template.first({ useMasterKey: true });
|
||||
if (res) {
|
||||
const isArchive = res.get('IsArchive');
|
||||
|
||||
@@ -25,6 +25,7 @@ export default async function getTemplate(request, response) {
|
||||
Template.include('Folder');
|
||||
Template.include('ExtUserPtr');
|
||||
Template.include('Placeholders.signerPtr');
|
||||
Template.include('ExtUserPtr.TenantId');
|
||||
const res = await Template.first({ useMasterKey: true });
|
||||
if (res) {
|
||||
const template = JSON.parse(JSON.stringify(res));
|
||||
|
||||
@@ -53,7 +53,7 @@ export default async function getTemplatetList(request, response) {
|
||||
'X-Parse-Application-Id': appId,
|
||||
'X-Parse-Master-Key': process.env.MASTER_KEY,
|
||||
};
|
||||
const url = `${serverUrl}/classes/${clsName}?where=${strParams}&keys=${strKeys}&order=${orderBy}&skip=${skip}&limit=${limit}&include=AuditTrail.UserPtr,Placeholders.signerPtr`;
|
||||
const url = `${serverUrl}/classes/${clsName}?where=${strParams}&keys=${strKeys}&order=${orderBy}&skip=${skip}&limit=${limit}&include=AuditTrail.UserPtr,Placeholders.signerPtr,ExtUserPtr.TenantId`;
|
||||
const res = await axios.get(url, { headers: headers });
|
||||
if (res.data && res.data.results.length > 0) {
|
||||
if (request.posthog) {
|
||||
|
||||
@@ -23,6 +23,7 @@ export default async function updateTemplate(request, response) {
|
||||
const template = new Parse.Query('contracts_Template');
|
||||
template.equalTo('objectId', request.params.template_id);
|
||||
template.equalTo('CreatedBy', userPtr);
|
||||
template.include('ExtUserPtr.TenantId');
|
||||
const res = await template.first({ useMasterKey: true });
|
||||
if (res) {
|
||||
const isArchive = res.get('IsArchive');
|
||||
|
||||
@@ -20,6 +20,7 @@ async function GetPublicTemplate(request) {
|
||||
templatQuery.descending('updatedAt');
|
||||
templatQuery.equalTo('IsPublic', true);
|
||||
templatQuery.notEqualTo('IsArchive', true);
|
||||
templatQuery.include('ExtUserPtr.TenantId');
|
||||
const getTemplate = await templatQuery.find({ useMasterKey: true });
|
||||
const extcls = new Parse.Query('contracts_Users');
|
||||
extcls.equalTo('Email', user.get('email'));
|
||||
|
||||
@@ -31,7 +31,13 @@ const saveRoleContact = async contact => {
|
||||
contactQuery.set('CreatedBy', contact.CreatedBy);
|
||||
contactQuery.set('UserId', contact.UserId);
|
||||
contactQuery.set('UserRole', 'contracts_Guest');
|
||||
contactQuery.set('TenantId', contact.TenantId);
|
||||
if (contact?.TenantId) {
|
||||
contactQuery.set('TenantId', {
|
||||
__type: 'Pointer',
|
||||
className: 'partners_Tenant',
|
||||
objectId: contact.TenantId,
|
||||
});
|
||||
}
|
||||
contactQuery.set('IsDeleted', false);
|
||||
const acl = new Parse.ACL();
|
||||
acl.setReadAccess(contact.CreatedBy.objectId, true);
|
||||
@@ -256,6 +262,7 @@ export default async function PublicUserLinkContactToDoc(req) {
|
||||
// Execute the query to get the template with the specified 'templateid'
|
||||
const docQuery = new Parse.Query('contracts_Template');
|
||||
docQuery.include('ExtUserPtr');
|
||||
docQuery.include('ExtUserPtr.TenantId');
|
||||
const tempRes = await docQuery.get(templateid, { useMasterKey: true });
|
||||
// Check if the template was found; if not, throw an error indicating the template was not found
|
||||
if (!tempRes) {
|
||||
@@ -317,7 +324,7 @@ export default async function PublicUserLinkContactToDoc(req) {
|
||||
Email: email,
|
||||
Phone: _extUser?.Phone ? _extUser.Phone : '',
|
||||
CreatedBy: _tempRes.CreatedBy,
|
||||
TenantId: _tempRes.ExtUserPtr.TenantId,
|
||||
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
||||
};
|
||||
const template_json = JSON.parse(JSON.stringify(tempRes));
|
||||
// if user present on platform create contact on the basis of extended user details
|
||||
@@ -344,7 +351,7 @@ export default async function PublicUserLinkContactToDoc(req) {
|
||||
Email: email,
|
||||
Phone: phone,
|
||||
CreatedBy: _tempRes.CreatedBy,
|
||||
TenantId: _tempRes.ExtUserPtr.TenantId,
|
||||
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
||||
};
|
||||
const template_json = JSON.parse(JSON.stringify(tempRes));
|
||||
// Create new contract on the basis provided contact details by user and userId from _User class
|
||||
@@ -381,7 +388,7 @@ export default async function PublicUserLinkContactToDoc(req) {
|
||||
Email: email,
|
||||
Phone: phone,
|
||||
CreatedBy: _tempRes.CreatedBy,
|
||||
TenantId: _tempRes.ExtUserPtr.TenantId,
|
||||
TenantId: _tempRes.ExtUserPtr?.TenantId?.objectId,
|
||||
};
|
||||
const template_json = JSON.parse(JSON.stringify(tempRes));
|
||||
// Create new contract on the basis provided contact details by user and userId from _User class
|
||||
|
||||
@@ -44,6 +44,7 @@ export default async function TemplateAfterSave(request) {
|
||||
const Query = new Parse.Query('contracts_Template');
|
||||
Query.include('Signers');
|
||||
Query.include('CreatedBy');
|
||||
Query.include('ExtUserPtr.TenantId');
|
||||
const updateACL = await Query.get(objId, { useMasterKey: true });
|
||||
const res = JSON.parse(JSON.stringify(updateACL));
|
||||
// console.log("res");
|
||||
@@ -85,6 +86,7 @@ export default async function TemplateAfterSave(request) {
|
||||
|
||||
const Query = new Parse.Query('contracts_Template');
|
||||
Query.include('CreatedBy');
|
||||
Query.include('ExtUserPtr.TenantId');
|
||||
const updateACL = await Query.get(objId, { useMasterKey: true });
|
||||
const res = JSON.parse(JSON.stringify(updateACL));
|
||||
// console.log("res");
|
||||
|
||||
@@ -29,7 +29,13 @@ const saveRoleContact = async contact => {
|
||||
contactQuery.set('CreatedBy', contact.CreatedBy);
|
||||
contactQuery.set('UserId', contact.UserId);
|
||||
contactQuery.set('UserRole', 'contracts_Guest');
|
||||
contactQuery.set('TenantId', contact.TenantId);
|
||||
if (contact?.TenantId) {
|
||||
contactQuery.set('TenantId', {
|
||||
__type: 'Pointer',
|
||||
className: 'partners_Tenant',
|
||||
objectId: contact.TenantId,
|
||||
});
|
||||
}
|
||||
contactQuery.set('IsDeleted', false);
|
||||
const acl = new Parse.ACL();
|
||||
acl.setReadAccess(contact.CreatedBy.objectId, true);
|
||||
@@ -125,7 +131,7 @@ export default async function linkContactToDoc(req) {
|
||||
Email: email,
|
||||
Phone: _extUser?.Phone ? _extUser.Phone : '',
|
||||
CreatedBy: _docRes.CreatedBy,
|
||||
TenantId: _docRes.ExtUserPtr.TenantId,
|
||||
TenantId: _docRes.ExtUserPtr?.TenantId?.objectId,
|
||||
};
|
||||
// if user present on platform create contact on the basis of extended user details
|
||||
const contactRes = await saveRoleContact(contact);
|
||||
@@ -177,7 +183,7 @@ export default async function linkContactToDoc(req) {
|
||||
Email: email,
|
||||
Phone: phone,
|
||||
CreatedBy: _docRes.CreatedBy,
|
||||
TenantId: _docRes.ExtUserPtr.TenantId,
|
||||
TenantId: _docRes.ExtUserPtr?.TenantId?.objectId,
|
||||
};
|
||||
// Create new contract on the basis provided contact details by user and userId from _User class
|
||||
const contactRes = await saveRoleContact(contact);
|
||||
@@ -234,7 +240,7 @@ export default async function linkContactToDoc(req) {
|
||||
Email: email,
|
||||
Phone: phone,
|
||||
CreatedBy: _docRes.CreatedBy,
|
||||
TenantId: _docRes.ExtUserPtr.TenantId,
|
||||
TenantId: _docRes.ExtUserPtr?.TenantId?.objectId,
|
||||
};
|
||||
// Create new contract on the basis provided contact details by user and userId from _User class
|
||||
const contactRes = await saveRoleContact(contact);
|
||||
@@ -274,7 +280,7 @@ export default async function linkContactToDoc(req) {
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('Err', err);
|
||||
console.log('Err while creating contact link to doc', err);
|
||||
}
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||
|
||||
Reference in New Issue
Block a user