mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-24 16:42:33 +02:00
refactor: changes in cloud function
This commit is contained in:
@@ -0,0 +1,26 @@
|
||||
export default async function getAllUserTeamByOrg(request) {
|
||||
const OrgId = request.params.orgId;
|
||||
if (!request?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
}
|
||||
try {
|
||||
const teamCls = new Parse.Query('contracts_Teams');
|
||||
teamCls.equalTo('OrganizationId', {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Organizations',
|
||||
objectId: OrgId,
|
||||
});
|
||||
teamCls.equalTo('IsActive', true);
|
||||
const teamRes = await teamCls.first({ useMasterKey: true });
|
||||
if (teamRes) {
|
||||
return teamRes;
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'Team not found.');
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('err in getOrganizations', err);
|
||||
const code = err?.code || 400;
|
||||
const msg = err?.message || 'Something went wrong.';
|
||||
throw new Parse.Error(code, msg);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user