Fixed global ESLint issues
MODIFY
src/server/rest/v1/service/AuthorizationService.ts
src/server/rest/v1/service/AuthorizationService.ts
@@ -29,7 +29,7 @@ export default class AuthorizationService {
};
// Check Projection
if (!Utils.isEmptyArray(filteredRequest.ProjectFields)) {
- authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField))
+ authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField));
}
// Not an Admin?
if (userToken.role !== UserRole.ADMIN) {
@@ -47,7 +47,7 @@ export default class AuthorizationService {
return authorizationFilters;
}
- public static async addSitesAuthorizations(tenant: Tenant, userToken: UserToken, sites: Site[]) {
+ public static async addSitesAuthorizations(tenant: Tenant, userToken: UserToken, sites: Site[]): Promise<void> {
// Get Site Admins
const { siteAdminIDs, siteOwnerIDs } = await AuthorizationService.getSiteAdminOwnerIDs(tenant, userToken);
// Set to user
@@ -78,7 +78,7 @@ export default class AuthorizationService {
}
// Check Projection
if (!Utils.isEmptyArray(filteredRequest.ProjectFields)) {
- authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField))
+ authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField));
}
// Not an Admin?
if (userToken.role !== UserRole.ADMIN) {
@@ -89,9 +89,9 @@ export default class AuthorizationService {
authorizationFilters.filters.siteIDs = siteIDs;
// Check if filter is provided
if (filteredRequest.SiteID) {
- const siteIDs = filteredRequest.SiteID.split('|');
+ const filteredSiteIDs = filteredRequest.SiteID.split('|');
// Override
- authorizationFilters.filters.siteIDs = siteIDs.filter(
+ authorizationFilters.filters.siteIDs = filteredSiteIDs.filter(
(siteID) => authorizationFilters.filters.siteIDs.includes(siteID));
}
}
@@ -113,7 +113,7 @@ export default class AuthorizationService {
};
// Check projection
if (!Utils.isEmptyArray(filteredRequest.ProjectFields)) {
- authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField))
+ authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField));
}
// Not an Admin?
if (userToken.role !== UserRole.ADMIN) {
@@ -124,9 +124,9 @@ export default class AuthorizationService {
authorizationFilters.filters.siteIDs = siteIDs;
// Check if filter is provided
if (filteredRequest.SiteID) {
- const siteIDs = filteredRequest.SiteID.split('|');
+ const filteredSiteIDs = filteredRequest.SiteID.split('|');
// Override
- authorizationFilters.filters.siteIDs = siteIDs.filter(
+ authorizationFilters.filters.siteIDs = filteredSiteIDs.filter(
(siteID) => authorizationFilters.filters.siteIDs.includes(siteID));
}
}
@@ -148,7 +148,7 @@ export default class AuthorizationService {
};
// Check projection
if (!Utils.isEmptyArray(filteredRequest.ProjectFields)) {
- authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField))
+ authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField));
}
// Not an Admin?
if (userToken.role !== UserRole.ADMIN) {
@@ -176,7 +176,7 @@ export default class AuthorizationService {
};
// Check projection
if (!Utils.isEmptyArray(filteredRequest.ProjectFields)) {
- authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField))
+ authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField));
}
// Not an Admin?
if (userToken.role !== UserRole.ADMIN) {
@@ -228,7 +228,7 @@ export default class AuthorizationService {
};
// Check projection
if (!Utils.isEmptyArray(filteredRequest.ProjectFields)) {
- authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField))
+ authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField));
}
// Get from users
const usersAuthorizationFilters = await AuthorizationService.checkAndGetUsersAuthorizationFilters(tenant, userToken, filteredRequest);
@@ -238,12 +238,12 @@ export default class AuthorizationService {
return authorizationFilters;
}
- public static async addUsersAuthorizations(tenant: Tenant, userToken: UserToken, users: User[]) {
+ public static addUsersAuthorizations(tenant: Tenant, userToken: UserToken, users: User[]): void {
// Enrich
for (const user of users) {
- user.canRead = Authorizations.canReadUser(userToken, user.id)
- user.canUpdate = Authorizations.canUpdateUser(userToken, user.id)
- user.canDelete = Authorizations.canDeleteUser(userToken, user.id)
+ user.canRead = Authorizations.canReadUser(userToken, user.id);
+ user.canUpdate = Authorizations.canUpdateUser(userToken, user.id);
+ user.canDelete = Authorizations.canDeleteUser(userToken, user.id);
}
}
@@ -259,7 +259,7 @@ export default class AuthorizationService {
};
// Check projection
if (!Utils.isEmptyArray(filteredRequest.ProjectFields)) {
- authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField))
+ authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField));
}
// Get from users
if (userToken.role === UserRole.BASIC) {
@@ -271,9 +271,9 @@ export default class AuthorizationService {
}
// Check if filter is provided
if (filteredRequest.SiteID) {
- const siteIDs = filteredRequest.SiteID.split('|');
+ const filteredSiteIDs = filteredRequest.SiteID.split('|');
// Override
- authorizationFilters.filters.siteIDs = siteIDs.filter(
+ authorizationFilters.filters.siteIDs = filteredSiteIDs.filter(
(siteID) => authorizationFilters.filters.siteIDs.includes(siteID));
}
}
@@ -291,7 +291,7 @@ export default class AuthorizationService {
};
// Check projection
if (!Utils.isEmptyArray(filteredRequest.ProjectFields)) {
- authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField))
+ authorizationFilters.projectFields = authorizationFilters.projectFields.filter((projectField) => filteredRequest.ProjectFields.includes(projectField));
}
// Not an Admin?
if (userToken.role !== UserRole.ADMIN) {
@@ -357,6 +357,6 @@ export default class AuthorizationService {
return {
siteAdminIDs,
siteOwnerIDs
- }
+ };
}
}

MODIFY
src/server/rest/v1/service/SiteService.ts
src/server/rest/v1/service/SiteService.ts
@@ -188,8 +188,7 @@ export default class SiteService {
module: MODULE_NAME, method: 'checkAndAssignSiteUsersAuthorizationFilters'
});
}
- } else {
- if (!Authorizations.canUnassignUsersSites(req.user)) {
+ } else if (!Authorizations.canUnassignUsersSites(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.ERROR,
user: req.user,
@@ -197,7 +196,6 @@ export default class SiteService {
module: MODULE_NAME, method: 'checkAndAssignSiteUsersAuthorizationFilters'
});
}
- }
// Filter
const filteredRequest = SiteSecurity.filterAssignSiteUsers(req.body);
// Check

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -120,8 +120,7 @@ export default class UserService {
module: MODULE_NAME, method: 'handleAssignSitesToUser'
});
}
- } else {
- if (!Authorizations.canUnassignUsersSites(req.user)) {
+ } else if (!Authorizations.canUnassignUsersSites(req.user)) {
throw new AppAuthError({
errorCode: HTTPAuthError.ERROR,
user: req.user,
@@ -129,7 +128,6 @@ export default class UserService {
module: MODULE_NAME, method: 'handleAssignSitesToUser'
});
}
- }
// Filter
const filteredRequest = UserSecurity.filterAssignSitesToUserRequest(req.body);
if (!filteredRequest.userID) {
@@ -859,7 +857,7 @@ export default class UserService {
authorizationFilters.projectFields
);
// Add Auth flags
- await AuthorizationService.addUsersAuthorizations(req.tenant, req.user, users.result);
+ AuthorizationService.addUsersAuthorizations(req.tenant, req.user, users.result);
// Return
res.json(users);
next();

Fixed global ESLint issues