Fixed typos and made company IDs list uniq
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -17,6 +17,7 @@ import TenantComponents from '../../../../types/TenantComponents';
import UserStorage from '../../../../storage/mongodb/UserStorage';
import UserToken from '../../../../types/UserToken';
import Utils from '../../../../utils/Utils';
+import _ from 'lodash';
const MODULE_NAME = 'AuthorizationService';
@@ -434,7 +435,7 @@ export default class AuthorizationService {
}, Constants.DB_PARAMS_MAX_LIMIT,
[ 'companyID' ]
);
- return sites.result.map((site) => site.companyID);
+ return _.uniq(_.map(sites.result, 'companyID'));
}
private static async getSiteAdminSiteIDs(tenantID: string, userToken: UserToken): Promise<string[]> {

MODIFY
src/server/rest/v1/service/CompanyService.ts
src/server/rest/v1/service/CompanyService.ts
@@ -20,7 +20,7 @@ const MODULE_NAME = 'CompanyService';
export default class CompanyService {
- public static async handleDeleteCompany(action: ServerAction, req: Request, res: Response, next: NextFunction) {
+ public static async handleDeleteCompany(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Check if component is active
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ORGANIZATION,
Action.DELETE, Entity.COMPANY, MODULE_NAME, 'handleDeleteCompany');

Fixed typos and made company IDs list uniq