Add canCreate on getSiteArea, getSite, getCompany
MODIFY
src/server/rest/v1/service/CompanyService.ts
src/server/rest/v1/service/CompanyService.ts
@@ -104,6 +104,7 @@ export default class CompanyService {
// Add authorization
const assignedCompanies = await AuthorizationService.getAssignedSitesCompanyIDs(req.tenant.id, req.user);
company.canUpdate = company.issuer && (req.user.role === UserRole.ADMIN || (Authorizations.canUpdateCompany(req.user) && assignedCompanies.includes(company.id)));
+ company.canCreate = Authorizations.canCreateCompany(req.user);
// Return
res.json(company);
next();

MODIFY
src/server/rest/v1/service/SiteAreaService.ts
src/server/rest/v1/service/SiteAreaService.ts
@@ -342,6 +342,7 @@ export default class SiteAreaService {
// Add authorization
const updateSiteAreaAuthorization = await AuthorizationService.checkUpdateDeleteSiteAreaAuthorization(req.tenant,req.user, filteredRequest.ID);
siteArea.canUpdate = siteArea.issuer && (req.user.role === UserRole.ADMIN || (Authorizations.canUpdateSiteArea(req.user) && updateSiteAreaAuthorization));
+ siteArea.canCreate = Authorizations.canCreateSiteArea(req.user);
// Return
res.json(siteArea);
next();

MODIFY
src/server/rest/v1/service/SiteService.ts
src/server/rest/v1/service/SiteService.ts
@@ -430,6 +430,7 @@ export default class SiteService {
// Add authorization
const siteAdminIDs = await AuthorizationService.getSiteAdminSiteIDs(req.tenant.id, req.user);
site.canUpdate = site.issuer && (req.user.role === UserRole.ADMIN || (Authorizations.canUpdateSite(req.user) && siteAdminIDs.includes(site.id)));
+ site.canCreate = Authorizations.canCreateSite(req.user);
// Return
res.json(site);
next();

Add canCreate on getSiteArea, getSite, getCompany