deactivate ocpi before deleting the tag
MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -157,22 +157,6 @@ export default class TagService {
action: action
});
}
- // Delete the Tag
- await TagStorage.deleteTag(req.user.tenantID, tag.id);
- // Check if default deleted?
- if (tag.default) {
- // Clear all default
- await TagStorage.clearDefaultUserTag(req.user.tenantID, tag.userID);
- // Make the next active Tag the new default one
- const firstActiveTag = await TagStorage.getFirstActiveUserTag(req.user.tenantID, tag.userID, {
- issuer: true,
- });
- if (firstActiveTag) {
- // Set default
- firstActiveTag.default = true;
- await TagStorage.saveTag(req.user.tenantID, firstActiveTag);
- }
- }
// OCPI
if (Utils.isComponentActiveFromToken(req.user, TenantComponents.OCPI)) {
try {
@@ -200,6 +184,22 @@ export default class TagService {
});
}
}
+ // Delete the Tag
+ await TagStorage.deleteTag(req.user.tenantID, tag.id);
+ // Check if default deleted?
+ if (tag.default) {
+ // Clear all default
+ await TagStorage.clearDefaultUserTag(req.user.tenantID, tag.userID);
+ // Make the next active Tag the new default one
+ const firstActiveTag = await TagStorage.getFirstActiveUserTag(req.user.tenantID, tag.userID, {
+ issuer: true,
+ });
+ if (firstActiveTag) {
+ // Set default
+ firstActiveTag.default = true;
+ await TagStorage.saveTag(req.user.tenantID, firstActiveTag);
+ }
+ }
// Log
await Logging.logSecurityInfo({
tenantID: req.user.tenantID,

deactivate ocpi before deleting the tag