mirror of
https://github.com/OpenSignLabs/OpenSign.git
synced 2026-08-17 21:25:54 +02:00
feat: add validation for teams and organization
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -17,15 +17,8 @@ const AddTeam = (props) => {
|
||||
const getTeamList = async () => {
|
||||
setIsLoader(true);
|
||||
try {
|
||||
const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||
const teamCls = new Parse.Query("contracts_Teams");
|
||||
teamCls.equalTo("OrganizationId", {
|
||||
__type: "Pointer",
|
||||
className: "contracts_Organizations",
|
||||
objectId: extUser.OrganizationId.objectId
|
||||
});
|
||||
teamCls.equalTo("IsActive", true);
|
||||
const teamRes = await teamCls.find();
|
||||
const teams = await Parse.Cloud.run("getteams");
|
||||
const teamRes = JSON.parse(JSON.stringify(teams));
|
||||
if (teamRes.length > 0) {
|
||||
const _teamRes = JSON.parse(JSON.stringify(teamRes));
|
||||
const allUsersteam = _teamRes.find((x) => x.Name === "All Users");
|
||||
@@ -73,76 +66,47 @@ const AddTeam = (props) => {
|
||||
}
|
||||
}
|
||||
try {
|
||||
const localUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||
setIsLoader(true);
|
||||
const team = new Parse.Query("contracts_Teams");
|
||||
team.equalTo("Name", formdata.name);
|
||||
let data = { Name: formdata.name };
|
||||
if (updatedAncestors.length > 0) {
|
||||
const ParentId = updatedAncestors[updatedAncestors.length - 1];
|
||||
team.equalTo("ParentId", ParentId);
|
||||
data["ParentId"] = ParentId?.objectId;
|
||||
data["Ancestors"] = updatedAncestors;
|
||||
}
|
||||
if (localUser && localUser.OrganizationId) {
|
||||
team.equalTo("OrganizationId", {
|
||||
__type: "Pointer",
|
||||
className: "contracts_Organizations",
|
||||
objectId: localUser.OrganizationId.objectId
|
||||
const newTeamRes = await Parse.Cloud.run("addteam", data);
|
||||
// console.log("teamRes ", newTeamRes);
|
||||
if (updatedAncestors.length > 0) {
|
||||
const ParentId = teamList.find((x) => x.objectId === formdata.team);
|
||||
props.handleTeamInfo({
|
||||
objectId: newTeamRes.id,
|
||||
Name: formdata.name,
|
||||
ParentId: ParentId,
|
||||
Ancestors: updatedAncestors,
|
||||
IsActive: true
|
||||
});
|
||||
}
|
||||
const isTeam = await team.first();
|
||||
if (isTeam) {
|
||||
props.setIsAlert({ type: "info", msg: "Teams already exists." });
|
||||
setIsLoader(false);
|
||||
} else {
|
||||
const newTeam = new Parse.Object("contracts_Teams");
|
||||
newTeam.set("Name", formdata.name);
|
||||
if (updatedAncestors.length > 0) {
|
||||
const ParentId = updatedAncestors[updatedAncestors.length - 1];
|
||||
newTeam.set("ParentId", ParentId);
|
||||
newTeam.set("Ancestors", updatedAncestors);
|
||||
}
|
||||
if (localUser && localUser.OrganizationId) {
|
||||
newTeam.set("OrganizationId", {
|
||||
__type: "Pointer",
|
||||
className: "contracts_Organizations",
|
||||
objectId: localUser.OrganizationId.objectId
|
||||
});
|
||||
}
|
||||
newTeam.set("IsActive", true);
|
||||
const newTeamRes = await newTeam.save();
|
||||
if (updatedAncestors.length > 0) {
|
||||
const ParentId = teamList.find((x) => x.objectId === formdata.team);
|
||||
props.handleTeamInfo({
|
||||
objectId: newTeamRes.id,
|
||||
Name: formdata.name,
|
||||
ParentId: ParentId,
|
||||
Ancestors: updatedAncestors,
|
||||
IsActive: true
|
||||
});
|
||||
} else {
|
||||
props.handleTeamInfo({
|
||||
objectId: newTeamRes.id,
|
||||
Name: formdata.name,
|
||||
ParentId: "",
|
||||
Ancestors: "",
|
||||
IsActive: true
|
||||
});
|
||||
}
|
||||
|
||||
if (props.closePopup) {
|
||||
props.closePopup();
|
||||
}
|
||||
setFormdata({
|
||||
name: "",
|
||||
team: { name: "", objectId: "" }
|
||||
});
|
||||
props.setIsAlert({
|
||||
type: "success",
|
||||
msg: "Team created successfully."
|
||||
props.handleTeamInfo({
|
||||
objectId: newTeamRes.id,
|
||||
Name: formdata.name,
|
||||
ParentId: "",
|
||||
Ancestors: "",
|
||||
IsActive: true
|
||||
});
|
||||
}
|
||||
if (props.closePopup) {
|
||||
props.closePopup();
|
||||
}
|
||||
setFormdata({ name: "", team: { name: "", objectId: "" } });
|
||||
props.setIsAlert({ type: "success", msg: "Team created successfully." });
|
||||
} catch (err) {
|
||||
console.log("err in save team", err);
|
||||
props.setIsAlert({ type: "danger", msg: "Something went wrong." });
|
||||
if (err.code === 137) {
|
||||
props.setIsAlert({ type: "danger", msg: "Teams already exists." });
|
||||
} else if (err.code === 102) {
|
||||
props.setIsAlert({ type: "warning", msg: "Provide team name." });
|
||||
} else {
|
||||
props.setIsAlert({ type: "danger", msg: "Something went wrong." });
|
||||
}
|
||||
} finally {
|
||||
setTimeout(() => props.setIsAlert({ type: "success", msg: "" }), 1500);
|
||||
setIsLoader(false);
|
||||
|
||||
@@ -3,10 +3,10 @@ export const templateCls = "contracts_Template";
|
||||
export const documentCls = "contracts_Document";
|
||||
export const themeColor = "#47a3ad";
|
||||
export const iconColor = "#686968";
|
||||
export const isEnableSubscription =
|
||||
process.env.REACT_APP_ENABLE_SUBSCRIPTION &&
|
||||
process.env.REACT_APP_ENABLE_SUBSCRIPTION?.toLowerCase() === "true"
|
||||
? true
|
||||
: false;
|
||||
export const isStaging =
|
||||
window.location.origin === "https://staging-app.opensignlabs.com";
|
||||
export const isEnableSubscription = true;
|
||||
// process.env.REACT_APP_ENABLE_SUBSCRIPTION &&
|
||||
// process.env.REACT_APP_ENABLE_SUBSCRIPTION?.toLowerCase() === "true"
|
||||
// ? true
|
||||
// : false;
|
||||
export const isStaging = "http://localhost:3001";
|
||||
// window.location.origin === "https://staging-app.opensignlabs.com";
|
||||
|
||||
@@ -113,16 +113,9 @@ const TeamList = () => {
|
||||
: false;
|
||||
setIsAdmin(admin);
|
||||
}
|
||||
const teamCls = new Parse.Query("contracts_Teams");
|
||||
teamCls.equalTo("OrganizationId", {
|
||||
__type: "Pointer",
|
||||
className: "contracts_Organizations",
|
||||
objectId: extUser.OrganizationId.objectId
|
||||
});
|
||||
teamCls.descending("createdAt");
|
||||
const teamRes = await teamCls.find();
|
||||
if (teamRes.length > 0) {
|
||||
const _teamRes = JSON.parse(JSON.stringify(teamRes));
|
||||
const teams = await Parse.Cloud.run("getteams");
|
||||
if (teams.length > 0) {
|
||||
const _teamRes = JSON.parse(JSON.stringify(teams));
|
||||
setTeamList(_teamRes);
|
||||
}
|
||||
} catch (err) {
|
||||
@@ -169,10 +162,11 @@ const TeamList = () => {
|
||||
newArray[index] = { ...newArray[index], IsActive: !IsActive };
|
||||
setTeamList(newArray);
|
||||
try {
|
||||
const teamCls = new Parse.Object("contracts_Teams");
|
||||
teamCls.id = team.objectId;
|
||||
teamCls.set("IsActive", !IsActive);
|
||||
await teamCls.save();
|
||||
await Parse.Cloud.run("updateteam", {
|
||||
IsActive: !IsActive,
|
||||
TeamId: team.objectId
|
||||
});
|
||||
// console.log("teamRes ", teamRes);
|
||||
setIsAlert({
|
||||
type: !IsActive === false ? "danger" : "success",
|
||||
msg: !IsActive === false ? "Team disabled." : "Team enabled."
|
||||
@@ -203,10 +197,9 @@ const TeamList = () => {
|
||||
setIsActLoader({ [team.objectId]: true });
|
||||
setIsEditModal({});
|
||||
try {
|
||||
const teamCls = new Parse.Object("contracts_Teams");
|
||||
teamCls.id = team?.objectId;
|
||||
teamCls.set("Name", team.Name);
|
||||
await teamCls.save();
|
||||
const data = { Name: team.Name, TeamId: team.objectId };
|
||||
await Parse.Cloud.run("updateteam", data);
|
||||
// console.log("updateTeamRes ", updateTeamRes);
|
||||
setIsAlert({ type: "success", msg: "Team Update successfully." });
|
||||
} catch (Err) {
|
||||
console.log("Err in update team name"), Err;
|
||||
|
||||
@@ -145,14 +145,7 @@ const ReportTable = (props) => {
|
||||
try {
|
||||
const extUser = JSON.parse(localStorage.getItem("Extand_Class"))?.[0];
|
||||
if (extUser?.OrganizationId?.objectId) {
|
||||
const team = new Parse.Query("contracts_Teams");
|
||||
team.equalTo("OrganizationId", {
|
||||
__type: "Pointer",
|
||||
className: "contracts_Organizations",
|
||||
objectId: extUser.OrganizationId.objectId
|
||||
});
|
||||
team.notEqualTo("IsActive", false);
|
||||
const teamtRes = await team.find();
|
||||
const teamtRes = await Parse.Cloud.run("getteams");
|
||||
if (teamtRes.length > 0) {
|
||||
const _teamRes = JSON.parse(JSON.stringify(teamtRes));
|
||||
const formatedList = _teamRes.map((x) => ({
|
||||
|
||||
@@ -52,6 +52,12 @@ import AddAdmin from './parsefunction/AddAdmin.js';
|
||||
import CheckAdminExist from './parsefunction/CheckAdminExist.js';
|
||||
import UpdateExistUserAsAdmin from './parsefunction/UpdateExistUserAsAdmin.js';
|
||||
import Newsletter from './parsefunction/Newsletter.js';
|
||||
import getOrganizations from './parsefunction/getOrganizations.js';
|
||||
import addOrganization from './parsefunction/addOrganization.js';
|
||||
import updateOrganization from './parsefunction/updateOrganization.js';
|
||||
import getTeams from './parsefunction/getTeams.js';
|
||||
import addTeam from './parsefunction/addTeam.js';
|
||||
import updateTeam from './parsefunction/updateTeam.js';
|
||||
|
||||
// This afterSave function triggers after an object is added or updated in the specified class, allowing for post-processing logic.
|
||||
Parse.Cloud.afterSave('contracts_Document', DocumentAftersave);
|
||||
@@ -113,3 +119,9 @@ Parse.Cloud.define('addadmin', AddAdmin);
|
||||
Parse.Cloud.define('checkadminexist', CheckAdminExist);
|
||||
Parse.Cloud.define('updateuserasadmin', UpdateExistUserAsAdmin);
|
||||
Parse.Cloud.define('newsletter', Newsletter);
|
||||
Parse.Cloud.define('getorganizations', getOrganizations);
|
||||
Parse.Cloud.define('addorganization', addOrganization);
|
||||
Parse.Cloud.define('updateorganization', updateOrganization);
|
||||
Parse.Cloud.define('getteams', getTeams);
|
||||
Parse.Cloud.define('addteam', addTeam);
|
||||
Parse.Cloud.define('updateteam', updateTeam);
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
export default async function addOrganization(request) {
|
||||
const name = request.params.name;
|
||||
|
||||
if (!request?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
}
|
||||
try {
|
||||
const extUserQuery = new Parse.Query('contracts_Users');
|
||||
extUserQuery.equalTo('UserId', {
|
||||
__type: 'Pointer',
|
||||
className: '_User',
|
||||
objectId: request.user.id,
|
||||
});
|
||||
extUserQuery.notEqualTo('IsDisabled', true);
|
||||
const resExt = await extUserQuery.first({ useMasterKey: true });
|
||||
if (!resExt) {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||
}
|
||||
const _resExt = JSON.parse(JSON.stringify(resExt));
|
||||
|
||||
const orgQuery = new Parse.Query('contracts_Organizations');
|
||||
orgQuery.equalTo('Name', name);
|
||||
orgQuery.equalTo('CreatedBy', {
|
||||
__type: 'Pointer',
|
||||
className: '_User',
|
||||
objectId: request.user.id,
|
||||
});
|
||||
const resOrg = await orgQuery.first({ useMasterKey: true });
|
||||
if (resOrg) {
|
||||
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'Organization already exists.');
|
||||
} else {
|
||||
const newOrg = new Parse.Object('contracts_Organizations');
|
||||
newOrg.set('Name', name);
|
||||
newOrg.set('IsActive', true);
|
||||
newOrg.set('CreatedBy', {
|
||||
__type: 'Pointer',
|
||||
className: '_User',
|
||||
objectId: request.user.id,
|
||||
});
|
||||
newOrg.set('TenantId', {
|
||||
__type: 'Pointer',
|
||||
className: 'partners_Tenant',
|
||||
objectId: _resExt.TenantId.objectId,
|
||||
});
|
||||
newOrg.set('ExtUserId', {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Users',
|
||||
objectId: resExt.id,
|
||||
});
|
||||
const newResOrg = await newOrg.save(null, { useMasterKey: true });
|
||||
if (newResOrg) {
|
||||
return newResOrg;
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('err in addorganization', err);
|
||||
const code = err?.code || 400;
|
||||
const msg = err?.message || 'Something went wrong.';
|
||||
throw new Parse.Error(code, msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
export default async function addTeam(request) {
|
||||
const Name = request.params.Name;
|
||||
const ParentId = request.params.ParentId;
|
||||
const Ancestors = request.params.Ancestors;
|
||||
const ParentPtr = { __type: 'Pointer', className: 'contracts_Teams', objectId: ParentId };
|
||||
if (Name) {
|
||||
if (!request?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
}
|
||||
try {
|
||||
const extUserQuery = new Parse.Query('contracts_Users');
|
||||
extUserQuery.equalTo('UserId', {
|
||||
__type: 'Pointer',
|
||||
className: '_User',
|
||||
objectId: request.user.id,
|
||||
});
|
||||
extUserQuery.notEqualTo('IsDisabled', true);
|
||||
const resExt = await extUserQuery.first({ useMasterKey: true });
|
||||
const extUser = JSON.parse(JSON.stringify(resExt));
|
||||
if (!extUser) {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||
}
|
||||
const teamCls = new Parse.Query('contracts_Teams');
|
||||
teamCls.equalTo('Name', Name);
|
||||
teamCls.equalTo('OrganizationId', {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Organizations',
|
||||
objectId: extUser.OrganizationId.objectId,
|
||||
});
|
||||
if (ParentId) {
|
||||
teamCls.equalTo('ParentId', ParentPtr);
|
||||
}
|
||||
const teamRes = await teamCls.first({ useMasterKey: true });
|
||||
if (teamRes) {
|
||||
throw new Parse.Error(Parse.Error.DUPLICATE_VALUE, 'Team already exists.');
|
||||
} else {
|
||||
const newteam = new Parse.Object('contracts_Teams');
|
||||
newteam.set('Name', Name);
|
||||
newteam.set('OrganizationId', {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Organizations',
|
||||
objectId: extUser.OrganizationId.objectId,
|
||||
});
|
||||
if (ParentId) {
|
||||
newteam.set('ParentId', ParentPtr);
|
||||
}
|
||||
if (Ancestors && Ancestors.length > 0) {
|
||||
newteam.set('Ancestors', Ancestors);
|
||||
}
|
||||
newteam.set('IsActive', true);
|
||||
const newTeamRes = await newteam.save(null, { useMasterKey: true });
|
||||
return newTeamRes;
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.INVALID_QUERY, 'Please provide parameters');
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,36 @@
|
||||
export default async function getOrganizations(request) {
|
||||
const limit = request.params.limit || 200;
|
||||
const skip = request.params.skip || 0;
|
||||
const extUserId = request.params.extUserId;
|
||||
if (!request?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
}
|
||||
try {
|
||||
const orgQuery = new Parse.Query('contracts_Organizations');
|
||||
orgQuery.equalTo('CreatedBy', {
|
||||
__type: 'Pointer',
|
||||
className: '_User',
|
||||
objectId: request.user.id,
|
||||
});
|
||||
orgQuery.equalTo('ExtUserId', {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Users',
|
||||
objectId: extUserId,
|
||||
});
|
||||
orgQuery.equalTo('IsActive', true);
|
||||
orgQuery.exclude('ExtUserId');
|
||||
orgQuery.limit(limit);
|
||||
orgQuery.skip(skip);
|
||||
const resOrg = await orgQuery.find({ useMasterKey: true });
|
||||
if (resOrg && resOrg.length > 0) {
|
||||
return resOrg;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
export default async function getTeams(request) {
|
||||
if (!request?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
}
|
||||
try {
|
||||
const extUserQuery = new Parse.Query('contracts_Users');
|
||||
extUserQuery.equalTo('UserId', {
|
||||
__type: 'Pointer',
|
||||
className: '_User',
|
||||
objectId: request.user.id,
|
||||
});
|
||||
extUserQuery.notEqualTo('IsDisabled', true);
|
||||
const resExt = await extUserQuery.first({ useMasterKey: true });
|
||||
const extUser = JSON.parse(JSON.stringify(resExt));
|
||||
const teamCls = new Parse.Query('contracts_Teams');
|
||||
teamCls.equalTo('OrganizationId', {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Organizations',
|
||||
objectId: extUser.OrganizationId.objectId,
|
||||
});
|
||||
teamCls.equalTo('IsActive', true);
|
||||
teamCls.descending('createdAt');
|
||||
const teamRes = await teamCls.find({ useMasterKey: true });
|
||||
if (teamRes && teamRes.length > 0) {
|
||||
return teamRes;
|
||||
} else {
|
||||
return [];
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
export default async function updateOrganization(request) {
|
||||
const orgId = request.params.orgId;
|
||||
const isactive = request.params.isactive;
|
||||
if (!request?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
}
|
||||
try {
|
||||
const orgQuery = new Parse.Query('contracts_Organizations');
|
||||
orgQuery.equalTo('objectId', orgId);
|
||||
orgQuery.equalTo('CreatedBy', {
|
||||
__type: 'Pointer',
|
||||
className: '_User',
|
||||
objectId: request.user.id,
|
||||
});
|
||||
const resOrg = await orgQuery.first({ useMasterKey: true });
|
||||
if (resOrg) {
|
||||
const newOrg = new Parse.Object('contracts_Organizations');
|
||||
newOrg.id = orgId;
|
||||
newOrg.set('IsActive', isactive);
|
||||
const newResOrg = await newOrg.save(null, { useMasterKey: true });
|
||||
if (newResOrg) {
|
||||
return newResOrg;
|
||||
}
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, 'Premission denied.');
|
||||
}
|
||||
} catch (err) {
|
||||
console.log('err in addorganization', err);
|
||||
const code = err?.code || 400;
|
||||
const msg = err?.message || 'Something went wrong.';
|
||||
throw new Parse.Error(code, msg);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
export default async function updateTeam(request) {
|
||||
const TeamId = request.params.TeamId;
|
||||
const IsActive = request.params.IsActive;
|
||||
const Name = request.params.Name;
|
||||
if (!request?.user) {
|
||||
throw new Parse.Error(Parse.Error.INVALID_SESSION_TOKEN, 'User is not authenticated.');
|
||||
}
|
||||
try {
|
||||
const extUserQuery = new Parse.Query('contracts_Users');
|
||||
extUserQuery.equalTo('UserId', {
|
||||
__type: 'Pointer',
|
||||
className: '_User',
|
||||
objectId: request.user.id,
|
||||
});
|
||||
extUserQuery.notEqualTo('IsDisabled', true);
|
||||
const resExt = await extUserQuery.first({ useMasterKey: true });
|
||||
const extUser = JSON.parse(JSON.stringify(resExt));
|
||||
if (!extUser) {
|
||||
throw new Parse.Error(Parse.Error.OBJECT_NOT_FOUND, 'User not found.');
|
||||
}
|
||||
const teamCls = new Parse.Query('contracts_Teams');
|
||||
teamCls.equalTo('objectId', TeamId);
|
||||
teamCls.equalTo('OrganizationId', {
|
||||
__type: 'Pointer',
|
||||
className: 'contracts_Organizations',
|
||||
objectId: extUser.OrganizationId.objectId,
|
||||
});
|
||||
const teamRes = await teamCls.first({ useMasterKey: true });
|
||||
if (teamRes) {
|
||||
const updateteam = new Parse.Object('contracts_Teams');
|
||||
updateteam.id = TeamId;
|
||||
if (Name) {
|
||||
updateteam.set('Name', Name);
|
||||
}
|
||||
if (IsActive) {
|
||||
updateteam.set('IsActive', IsActive);
|
||||
}
|
||||
const updateTeamRes = await updateteam.save(null, { useMasterKey: true });
|
||||
return updateTeamRes;
|
||||
} else {
|
||||
throw new Parse.Error(Parse.Error.OPERATION_FORBIDDEN, 'Premission denied.');
|
||||
}
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
@@ -38,7 +38,16 @@ exports.up = async Parse => {
|
||||
.addBoolean('HeaderDocId')
|
||||
.addPointer('CreatedBy', '_User')
|
||||
.addString('Webhook')
|
||||
.addBoolean('ShareWithTeam', false);
|
||||
.addBoolean('ShareWithTeam', false)
|
||||
.setCLP({
|
||||
get: {},
|
||||
find: {},
|
||||
count: {},
|
||||
create: { '*': true },
|
||||
update: { '*': true },
|
||||
delete: {},
|
||||
addField: {},
|
||||
});
|
||||
await extUsers.save(null, { useMasterKey: true });
|
||||
|
||||
const doc = new Parse.Schema('contracts_Document');
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
/**
|
||||
*
|
||||
* @param {Parse} Parse
|
||||
*/
|
||||
exports.up = async Parse => {
|
||||
const teamSchema = new Parse.Schema('contracts_Teams');
|
||||
teamSchema.setCLP({
|
||||
get: {},
|
||||
find: {},
|
||||
count: {},
|
||||
create: {},
|
||||
update: {},
|
||||
delete: {},
|
||||
addField: {},
|
||||
});
|
||||
await teamSchema.update();
|
||||
|
||||
const orgSchema = new Parse.Schema('contracts_Organizations');
|
||||
orgSchema.setCLP({
|
||||
get: {},
|
||||
find: {},
|
||||
count: {},
|
||||
create: {},
|
||||
update: {},
|
||||
delete: {},
|
||||
addField: {},
|
||||
});
|
||||
|
||||
return orgSchema.update();
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {Parse} Parse
|
||||
*/
|
||||
exports.down = async Parse => {
|
||||
const teamSchema = new Parse.Schema('contracts_Teams');
|
||||
teamSchema.setCLP({
|
||||
get: { '*': true },
|
||||
find: { '*': true },
|
||||
count: { '*': true },
|
||||
create: { '*': true },
|
||||
update: { '*': true },
|
||||
delete: { '*': true },
|
||||
addField: { '*': true },
|
||||
});
|
||||
await teamSchema.update();
|
||||
|
||||
const orgSchema = new Parse.Schema('contracts_Organizations');
|
||||
orgSchema.setCLP({
|
||||
get: { '*': true },
|
||||
find: { '*': true },
|
||||
count: { '*': true },
|
||||
create: { '*': true },
|
||||
update: { '*': true },
|
||||
delete: { '*': true },
|
||||
addField: { '*': true },
|
||||
});
|
||||
|
||||
return orgSchema.update();
|
||||
};
|
||||
Reference in New Issue
Block a user