mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
feat: create duplicate template functionality feat: add support of csv and xlsx for bulk contacts import feat: add info text for forms and dashboard button feat: implement functionality to delete a PDF page while editing the document feat: show completed documents in which signers included but not owner in completed reports feat: add delete folder button in opensign drive feat: introduce Bcc email support for sending completed documents feat: allow merging multiple pdf while drafting document and template feat: add 'My Initials' tab for auto-signing in request-sign flow feat: add support for redirect URL to navigate after document completion feat: introduce privacy policy and digital signature terms before signing documents. feat: add feature to allow adding new pages to existing document feat: add save signature, initials, stamp functionality in sign pad for logged in user feat: add preferences menu feat: add save custom email template, notifyonsignature, set timezone, allow signature types in preferences feat: secure local url feat: implement Italian language translation feat: implement German language translation feat: update menu name from report to documents and shift contactbook in main menu feat: provide edit contact functionality fix: unable to delete folder when all its documents are deleted fix: fields.push is not function fix: document loading issue in opensign drive fix: adjust the guest signature flow to display the document in full screen, eliminating any blank space which is displayed below the place holder in mobile view fix: resolve issue of instance of pdfdict or pdfstream but got undefined build(deps): update dependencies refactor: change note text from add contact form
72 lines
2.5 KiB
JavaScript
72 lines
2.5 KiB
JavaScript
async function ContactbookAftersave(request) {
|
|
/* In beforesave or aftersave if you want to check if an object is being inserted or updated
|
|
you can check as follows */
|
|
if (!request.original) {
|
|
const user = request.user;
|
|
const object = request.object;
|
|
if (object.get('UserId')) {
|
|
// Retrieve the current ACL
|
|
const acl = new Parse.ACL();
|
|
// Ensure the current user has read access
|
|
if (acl && request?.user) {
|
|
const object = request.object;
|
|
acl.setReadAccess(user, true);
|
|
acl.setWriteAccess(user, true);
|
|
acl.setReadAccess(object.get('UserId'), true);
|
|
acl.setWriteAccess(object.get('UserId'), true);
|
|
|
|
object.setACL(acl);
|
|
object.set('IsDeleted', false);
|
|
// Continue saving the object
|
|
return object.save(null, { useMasterKey: true });
|
|
}
|
|
} else {
|
|
const Name = object.get('Name');
|
|
const Email = object.get('Email');
|
|
const Phone = object.get('Phone');
|
|
try {
|
|
const _users = Parse.Object.extend('User');
|
|
const _user = new _users();
|
|
_user.set('name', Name);
|
|
_user.set('username', Email);
|
|
_user.set('email', Email);
|
|
_user.set('password', Email);
|
|
if (Email) {
|
|
_user.set('phone', Phone);
|
|
}
|
|
const user = await _user.save();
|
|
if (user) {
|
|
object.set('UserId', user);
|
|
const acl = object.getACL() || new Parse.ACL();
|
|
acl.setReadAccess(user.id, true);
|
|
acl.setWriteAccess(user.id, true);
|
|
object.setACL(acl);
|
|
await object.save(null, { useMasterKey: true });
|
|
// console.log('res update new user with contac', res);
|
|
}
|
|
} catch (err) {
|
|
// console.log('err ', err);
|
|
if (err.code === 202) {
|
|
const userQuery = new Parse.Query(Parse.User);
|
|
userQuery.equalTo('email', Email);
|
|
const userRes = await userQuery.first({ useMasterKey: true });
|
|
object.set('UserId', {
|
|
__type: 'Pointer',
|
|
className: '_User',
|
|
objectId: userRes.id,
|
|
});
|
|
const acl = object.getACL() || new Parse.ACL();
|
|
acl.setReadAccess(userRes.id, true);
|
|
acl.setWriteAccess(userRes.id, true);
|
|
object.setACL(acl);
|
|
await object.save(null, { useMasterKey: true });
|
|
// console.log('res update existing user with contact', res);
|
|
}
|
|
}
|
|
}
|
|
} else {
|
|
console.log('Object being update');
|
|
}
|
|
}
|
|
export default ContactbookAftersave;
|