Update checks for refactored method calls.
MODIFY
src/server/rest/v1/service/CarService.ts
src/server/rest/v1/service/CarService.ts
@@ -466,7 +466,7 @@ export default class CarService {
UtilsService.assertIdIsProvided(action, filteredRequest.ID, MODULE_NAME, 'handleGetCar', req.user);
// Check User
let userProject: string[] = [];
- if (await Authorizations.canReadUser(req.user)) {
+ if ((await Authorizations.canReadUser(req.user)).authorized) {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName', 'carUsers.id',
'carUsers.user.id', 'carUsers.user.name', 'carUsers.user.firstName', 'carUsers.user.email', 'carUsers.default', 'carUsers.owner'
];
@@ -615,7 +615,7 @@ export default class CarService {
UtilsService.assertObjectExists(action, foundUser, `User ID '${userToCheck.user.id}' does not exist`,
MODULE_NAME, 'handleAssignCarUsers', loggedUser);
// Auth
- if (!await Authorizations.canReadUser(loggedUser)) {
+ if (!(await Authorizations.canReadUser(loggedUser)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: loggedUser,

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -542,7 +542,7 @@ export default class ChargingStationService {
UtilsService.assertObjectExists(action, siteArea, `Site Area ID '${filteredRequest.SiteAreaID}' does not exist`,
MODULE_NAME, 'handleTriggerSmartCharging', req.user);
// Check auth
- if (!await Authorizations.canUpdateSiteArea(req.user)) {
+ if (!(await Authorizations.canUpdateSiteArea(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,

MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -372,7 +372,7 @@ export default class TagService {
// eslint-disable-next-line @typescript-eslint/require-await
public static async handleImportTags(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Check auth
- if (!await Authorizations.canImportTags(req.user)) {
+ if (!(await Authorizations.canImportTags(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -570,7 +570,7 @@ export default class TagService {
public static async handleExportTags(action: ServerAction, req: Request, res: Response, next: NextFunction): Promise<void> {
// Check auth
- if (!await Authorizations.canExportTags(req.user)) {
+ if (!(await Authorizations.canExportTags(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -566,7 +566,7 @@ export default class TransactionService {
});
}
// Check User
- if (!await Authorizations.canReadUser(req.user)) {
+ if (!(await Authorizations.canReadUser(req.user)).authorized) {
// Remove User
delete transaction.user;
delete transaction.userID;
@@ -646,7 +646,7 @@ export default class TransactionService {
});
}
// Check User
- if (!await Authorizations.canReadUser(req.user)) {
+ if (!(await Authorizations.canReadUser(req.user)).authorized) {
// Remove User
delete transaction.user;
delete transaction.userID;

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -69,7 +69,7 @@ export default class UserService {
const userID = UserSecurity.filterDefaultTagCarRequestByUserID(req.query);
UtilsService.assertIdIsProvided(action, userID, MODULE_NAME, 'handleGetUserDefaultTagCar', req.user);
// Check auth
- if (!await Authorizations.canReadUser(req.user)) {
+ if (!(await Authorizations.canReadUser(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -120,7 +120,7 @@ export default class UserService {
Action.UPDATE, Entity.SITES, 'SiteService', 'handleAssignSitesToUser');
// Check auth
if (action === ServerAction.ADD_SITES_TO_USER) {
- if (!await Authorizations.canAssignUsersSites(req.user)) {
+ if (!(await Authorizations.canAssignUsersSites(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -128,7 +128,7 @@ export default class UserService {
module: MODULE_NAME, method: 'handleAssignSitesToUser'
});
}
- } else if (!await Authorizations.canUnassignUsersSites(req.user)) {
+ } else if (!(await Authorizations.canUnassignUsersSites(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -151,7 +151,7 @@ export default class UserService {
});
}
// Check auth
- if (!await Authorizations.canReadUser(req.user)) {
+ if (!(await Authorizations.canReadUser(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -589,7 +589,7 @@ export default class UserService {
const filteredRequest = UserSecurity.filterUserRequest(req.query);
UtilsService.assertIdIsProvided(action, filteredRequest.ID, MODULE_NAME, 'handleGetUser', req.user);
// Check auth
- if (!await Authorizations.canReadUser(req.user)) {
+ if (!(await Authorizations.canReadUser(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -620,7 +620,7 @@ export default class UserService {
const userID = UserSecurity.filterUserByIDRequest(req.query);
UtilsService.assertIdIsProvided(action, userID, MODULE_NAME, 'handleGetUserImage', req.user);
// Check auth
- if (!await Authorizations.canReadUser(req.user)) {
+ if (!(await Authorizations.canReadUser(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -656,7 +656,7 @@ export default class UserService {
UtilsService.assertComponentIsActiveFromToken(req.user, TenantComponents.ORGANIZATION,
Action.UPDATE, Entity.USER, MODULE_NAME, 'handleGetSites');
// Check auth
- if (!await Authorizations.canListUsersSites(req.user)) {
+ if (!(await Authorizations.canListUsersSites(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,
@@ -668,7 +668,7 @@ export default class UserService {
const filteredRequest = UserSecurity.filterUserSitesRequest(req.query);
UtilsService.assertIdIsProvided(action, filteredRequest.UserID, MODULE_NAME, 'handleGetSites', req.user);
// Check auth
- if (!await Authorizations.canReadUser(req.user)) {
+ if (!(await Authorizations.canReadUser(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,

Update checks for refactored method calls.