handleUpdateCompany change. add 'await' in SiteService
MODIFY
src/server/rest/v1/service/CompanyService.ts
src/server/rest/v1/service/CompanyService.ts
@@ -221,6 +221,7 @@ export default class CompanyService {
Action.UPDATE, Entity.COMPANY, MODULE_NAME, 'handleUpdateCompany');
// Filter
const filteredRequest = CompanySecurity.filterCompanyUpdateRequest(req.body);
+ UtilsService.assertIdIsProvided(action, filteredRequest.id, MODULE_NAME, 'handleUpdateCompany', req.user);
// Check auth
if (!Authorizations.canUpdateCompany(req.user)) {
throw new AppAuthError({
@@ -231,8 +232,11 @@ export default class CompanyService {
value: filteredRequest.id
});
}
+ // Get authorization filters
+ const authorizationUserFilters = await AuthorizationService.checkAndGetCompanyAuthorizationFilters(
+ req.tenant, req.user, { ID: filteredRequest.id });
// Get Company
- const company = await CompanyStorage.getCompany(req.user.tenantID, filteredRequest.id);
+ const company = await CompanyStorage.getCompany(req.user.tenantID, filteredRequest.id, authorizationUserFilters.filters);
UtilsService.assertObjectExists(action, company, `Company with ID '${filteredRequest.id}' does not exist`,
MODULE_NAME, 'handleUpdateCompany', req.user);
// Check Mandatory fields

MODIFY
src/server/rest/v1/service/SiteService.ts
src/server/rest/v1/service/SiteService.ts
@@ -105,7 +105,7 @@ export default class SiteService {
// Update
await SiteStorage.updateSiteUserAdmin(req.user.tenantID, filteredRequest.siteID, filteredRequest.userID, filteredRequest.siteAdmin);
// Log
- Logging.logSecurityInfo({
+ await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
user: req.user, actionOnUser: user,
module: MODULE_NAME, method: 'handleUpdateSiteUserAdmin',
@@ -178,7 +178,7 @@ export default class SiteService {
// Update
await SiteStorage.updateSiteOwner(req.user.tenantID, filteredRequest.siteID, filteredRequest.userID, filteredRequest.siteOwner);
// Log
- Logging.logSecurityInfo({
+ await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
user: req.user, actionOnUser: user,
module: MODULE_NAME, method: 'handleUpdateSiteUserOwner',
@@ -264,7 +264,7 @@ export default class SiteService {
await SiteStorage.removeUsersFromSite(req.user.tenantID, filteredRequest.siteID, filteredRequest.userIDs);
}
// Log
- Logging.logSecurityInfo({
+ await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
user: req.user, module: MODULE_NAME, method: 'handleAssignUsersToSite',
message: 'Site\'s Users have been removed successfully', action: action
@@ -380,7 +380,7 @@ export default class SiteService {
// Delete
await SiteStorage.deleteSite(req.user.tenantID, site.id);
// Log
- Logging.logSecurityInfo({
+ await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
user: req.user, module: MODULE_NAME, method: 'handleDeleteSite',
message: `Site '${site.name}' has been deleted successfully`,
@@ -559,7 +559,7 @@ export default class SiteService {
// Save
site.id = await SiteStorage.saveSite(req.user.tenantID, site);
// Log
- Logging.logSecurityInfo({
+ await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
user: req.user, module: MODULE_NAME, method: 'handleCreateSite',
message: `Site '${site.name}' has been created successfully`,
@@ -648,7 +648,7 @@ export default class SiteService {
// Save
await SiteStorage.saveSite(req.user.tenantID, site, Utils.objectHasProperty(filteredRequest, 'image') ? true : false);
// Log
- Logging.logSecurityInfo({
+ await Logging.logSecurityInfo({
tenantID: req.user.tenantID,
user: req.user, module: MODULE_NAME, method: 'handleUpdateSite',
message: `Site '${site.name}' has been updated successfully`,

handleUpdateCompany change. add 'await' in SiteService