Handled harger token user info
MODIFY
src/server/rest/v1/service/RegistrationTokenService.ts
src/server/rest/v1/service/RegistrationTokenService.ts
@@ -207,6 +207,11 @@ export default class RegistrationTokenService {
});
}
const filteredRequest = RegistrationTokenSecurity.filterRegistrationTokensRequest(req.query);
+ // Check User
+ let userProject: string[] = [];
+ if (Authorizations.canListUsers(req.user)) {
+ userProject = [ 'createdBy.name', 'createdBy.firstName', 'lastChangedBy.name', 'lastChangedBy.firstName' ];
+ }
// Get the tokens
const registrationTokens = await RegistrationTokenStorage.getRegistrationTokens(req.user.tenantID,
{
@@ -219,7 +224,10 @@ export default class RegistrationTokenService {
sort: filteredRequest.Sort,
onlyRecordCount: filteredRequest.OnlyRecordCount
},
- [ 'id', 'status', 'description', 'createdOn', 'lastChangedOn', 'expirationDate', 'revocationDate', 'siteAreaID', 'siteArea.name' ]
+ [
+ 'id', 'status', 'description', 'createdOn', 'lastChangedOn', 'expirationDate', 'revocationDate', 'siteAreaID', 'siteArea.name',
+ ...userProject
+ ]
);
// Build OCPP URLs
registrationTokens.result.forEach((registrationToken) => {

MODIFY
src/storage/mongodb/RegistrationTokenStorage.ts
src/storage/mongodb/RegistrationTokenStorage.ts
@@ -119,6 +119,8 @@ export default class RegistrationTokenStorage {
aggregation.push({
$limit: (dbParams.limit > 0 && dbParams.limit < Constants.DB_RECORD_COUNT_CEIL) ? dbParams.limit : Constants.DB_RECORD_COUNT_CEIL
});
+ // Add Created By / Last Changed By
+ DatabaseUtils.pushCreatedLastChangedInAggregation(tenantID, aggregation);
// Project
DatabaseUtils.projectFields(aggregation, projectFields);
// Read DB

Handled harger token user info