Check authorizatios With the athorized flag
MODIFY
src/server/rest/v1/service/BillingService.ts
src/server/rest/v1/service/BillingService.ts
@@ -272,7 +272,7 @@ export default class BillingService {
}
// Check Users
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'userID', 'user.id', 'user.name', 'user.firstName', 'user.email' ];
}
// Filter
@@ -310,7 +310,7 @@ export default class BillingService {
UtilsService.assertIdIsProvided(action, filteredRequest.ID, MODULE_NAME, 'handleGetInvoice', req.user);
// Check Users
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'userID', 'user.id', 'user.name', 'user.firstName', 'user.email' ];
}
// Get invoice

MODIFY
src/server/rest/v1/service/CarService.ts
src/server/rest/v1/service/CarService.ts
@@ -426,7 +426,7 @@ export default class CarService {
const filteredRequest = CarSecurity.filterCarsRequest(req.query);
// Check User
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName',
'carUsers.user.id', 'carUsers.user.name', 'carUsers.user.firstName', 'carUsers.owner', 'carUsers.default' ];
}

MODIFY
src/server/rest/v1/service/ChargingStationService.ts
src/server/rest/v1/service/ChargingStationService.ts
@@ -1396,7 +1396,7 @@ export default class ChargingStationService {
const filteredRequest = ChargingStationValidator.getInstance().validateChargingStationsGetReq(req.query);
// Check Users
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = ['connectors.user.id', 'connectors.user.name', 'connectors.user.firstName', 'connectors.user.email'];
}
// Project fields

MODIFY
src/server/rest/v1/service/ConnectionService.ts
src/server/rest/v1/service/ConnectionService.ts
@@ -43,7 +43,7 @@ export default class ConnectionService {
}
// Check User
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName' ];
}
// Get it
@@ -69,7 +69,7 @@ export default class ConnectionService {
const filteredRequest = ConnectionSecurity.filterConnectionsRequest(req.query);
// Check Users
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName' ];
}
// Get

MODIFY
src/server/rest/v1/service/NotificationService.ts
src/server/rest/v1/service/NotificationService.ts
@@ -22,7 +22,7 @@ export default class NotificationService {
const filteredRequest = NotificationSecurity.filterNotificationsRequest(req.query);
// Check User
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'userID', 'user.id', 'user.name', 'user.firstName', 'user.email', 'data' ];
}
// Check Charging Station

MODIFY
src/server/rest/v1/service/OCPIEndpointService.ts
src/server/rest/v1/service/OCPIEndpointService.ts
@@ -106,7 +106,7 @@ export default class OCPIEndpointService {
}
// Check User
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName' ];
}
// Filter

MODIFY
src/server/rest/v1/service/OICPEndpointService.ts
src/server/rest/v1/service/OICPEndpointService.ts
@@ -191,7 +191,7 @@ export default class OICPEndpointService {
}
// Check User
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName' ];
}
// Filter

MODIFY
src/server/rest/v1/service/RegistrationTokenService.ts
src/server/rest/v1/service/RegistrationTokenService.ts
@@ -240,7 +240,7 @@ export default class RegistrationTokenService {
const filteredRequest = RegistrationTokenSecurity.filterRegistrationTokensRequest(req.query);
// Check User
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName' ];
}
// Get the tokens
@@ -279,7 +279,7 @@ export default class RegistrationTokenService {
const filteredRequest = RegistrationTokenSecurity.filterRegistrationTokenByIDRequest(req.query);
// Check User
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName' ];
}
// Get the token

MODIFY
src/server/rest/v1/service/TransactionService.ts
src/server/rest/v1/service/TransactionService.ts
@@ -544,7 +544,7 @@ export default class TransactionService {
];
}
}
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
projectFields = [
...projectFields,
'userID', 'user.id', 'user.name', 'user.firstName', 'user.email', 'tagID',
@@ -749,7 +749,7 @@ export default class TransactionService {
}
// Check Users
let userProject: string[] = [];
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
userProject = ['userID', 'user.id', 'user.name', 'user.firstName', 'user.email', 'tagID'];
}
const filter: any = { stop: { $exists: true } };
@@ -1039,7 +1039,7 @@ export default class TransactionService {
});
}
// Check Users
- if (await Authorizations.canListUsers(req.user)) {
+ if ((await Authorizations.canListUsers(req.user)).authorized) {
if (projectFields) {
projectFields = [
...projectFields,

MODIFY
src/server/rest/v1/service/UserService.ts
src/server/rest/v1/service/UserService.ts
@@ -1159,7 +1159,7 @@ export default class UserService {
private static async getUsers(req: Request, res: Response, next: NextFunction): Promise<DataResult<User>> {
// Check auth
- if (!await Authorizations.canListUsers(req.user)) {
+ if (!(await Authorizations.canListUsers(req.user)).authorized) {
throw new AppAuthError({
errorCode: HTTPAuthError.FORBIDDEN,
user: req.user,

Check authorizatios With the athorized flag