Skip to content

Commit

Permalink
fix: user does not exist error while signing
Browse files Browse the repository at this point in the history
  • Loading branch information
prafull-opensignlabs committed Nov 8, 2024
1 parent c88de90 commit ade228f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 23 deletions.
20 changes: 10 additions & 10 deletions apps/OpenSignServer/cloud/parsefunction/getTenant.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ async function getTenantByUserId(userId, contactId) {
contactquery.equalTo('objectId', contactId);
const contactuser = await contactquery.first({ useMasterKey: true });
if (contactuser) {
const user = contactuser?.get('CreatedBy')?.id || userId;
const tenantCreditsQuery = new Parse.Query('partners_Tenant');
tenantCreditsQuery.equalTo('UserId', {
__type: 'Pointer',
className: '_User',
objectId: user,
});
tenantCreditsQuery.exclude('FileAdapters,PfxFile,ContactNumber');
const res = await tenantCreditsQuery.first({ useMasterKey: true });
return res;
const tenantId = contactuser?.get('TenantId')?.id;
if (tenantId) {
const tenantCreditsQuery = new Parse.Query('partners_Tenant');
tenantCreditsQuery.equalTo('objectId', tenantId);
tenantCreditsQuery.exclude('FileAdapters,PfxFile,ContactNumber');
const res = await tenantCreditsQuery.first({ useMasterKey: true });
return res;
} else {
return {};
}
} else {
return {};
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export default async function isUserInContactBook(request) {
query.equalTo('CreatedBy', userPtr);
query.notEqualTo('IsDeleted', true);
query.equalTo('Email', email);
const res = await query.first();
const res = await query.first({ sessionToken: request.user.getSessionToken() });
return res;
}
} catch (err) {
Expand Down
24 changes: 12 additions & 12 deletions apps/OpenSignServer/cloud/parsefunction/savecontact.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export default async function savecontact(request) {
query.equalTo('CreatedBy', currentUserPtr);
query.notEqualTo('IsDeleted', true);
query.equalTo('Email', email);
const res = await query.first();
const res = await query.first({ sessionToken: request.user.getSessionToken() });
if (!res) {
const contactQuery = new Parse.Object('contracts_Contactbook');
contactQuery.set('Name', name);
Expand All @@ -24,7 +24,7 @@ export default async function savecontact(request) {
}
contactQuery.set('Email', email);
contactQuery.set('UserRole', 'contracts_Guest');

contactQuery.set('IsDeleted', false);
if (tenantId) {
contactQuery.set('TenantId', {
__type: 'Pointer',
Expand All @@ -49,8 +49,8 @@ export default async function savecontact(request) {
contactQuery.set('CreatedBy', currentUserPtr);
contactQuery.set('UserId', user);
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
acl.setPublicWriteAccess(true);
acl.setReadAccess(user.id, true);
acl.setWriteAccess(user.id, true);
acl.setReadAccess(currentUser.id, true);
acl.setWriteAccess(currentUser.id, true);
contactQuery.setACL(acl);
Expand All @@ -71,8 +71,8 @@ export default async function savecontact(request) {
objectId: userRes.id,
});
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
acl.setPublicWriteAccess(true);
acl.setReadAccess(userRes.id, true);
acl.setWriteAccess(userRes.id, true);
acl.setReadAccess(currentUser.id, true);
acl.setWriteAccess(currentUser.id, true);
contactQuery.setACL(acl);
Expand Down Expand Up @@ -105,7 +105,7 @@ export default async function savecontact(request) {
query.equalTo('CreatedBy', currentUserPtr);
query.notEqualTo('IsDeleted', true);
query.equalTo('Email', email);
const res = await query.first();
const res = await query.first({ useMasterKey: true });
if (!res) {
const contactQuery = new Parse.Object('contracts_Contactbook');
contactQuery.set('Name', name);
Expand All @@ -114,7 +114,7 @@ export default async function savecontact(request) {
}
contactQuery.set('Email', email);
contactQuery.set('UserRole', 'contracts_Guest');

contactQuery.set('IsDeleted', false);
if (tenantId) {
contactQuery.set('TenantId', {
__type: 'Pointer',
Expand All @@ -138,8 +138,8 @@ export default async function savecontact(request) {
contactQuery.set('CreatedBy', currentUserPtr);
contactQuery.set('UserId', user);
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
acl.setPublicWriteAccess(true);
acl.setReadAccess(user.id, true);
acl.setWriteAccess(user.id, true);
acl.setReadAccess(currentUser.id, true);
acl.setWriteAccess(currentUser.id, true);
contactQuery.setACL(acl);
Expand All @@ -160,8 +160,8 @@ export default async function savecontact(request) {
objectId: userRes.id,
});
const acl = new Parse.ACL();
acl.setPublicReadAccess(true);
acl.setPublicWriteAccess(true);
acl.setReadAccess(userRes.id, true);
acl.setWriteAccess(userRes.id, true);
acl.setReadAccess(currentUser.id, true);
acl.setWriteAccess(currentUser.id, true);
contactQuery.setACL(acl);
Expand Down

0 comments on commit ade228f

Please sign in to comment.