Basic user cannot assign inactive tag
MODIFY
src/server/rest/v1/service/TagService.ts
src/server/rest/v1/service/TagService.ts
@@ -229,6 +229,17 @@ export default class TagService {
action: action
});
}
+ // Check if tag is active
+ if (!tag.active) {
+ throw new AppError({
+ source: Constants.CENTRAL_SERVER,
+ errorCode: HTTPError.TAG_INACTIVE,
+ message: `Tag with visual ID '${filteredRequest.visualID}' is not active and cannot be assigned`,
+ module: MODULE_NAME, method: 'handleAssignTag',
+ user: req.user,
+ action: action
+ });
+ }
if (tag.user) {
throw new AppError({
source: Constants.CENTRAL_SERVER,
@@ -397,7 +408,7 @@ export default class TagService {
tag.description = filteredRequest.description;
tag.active = filteredRequest.active;
tag.userID = filteredRequest.userID;
- tag.default = filteredRequest.default;
+ tag.default = filteredRequest.userID ? filteredRequest.default : false;
tag.lastChangedBy = { id: req.user.id };
tag.lastChangedOn = new Date();
// Save
@@ -725,6 +736,7 @@ export default class TagService {
// Unassign the Tag
const userID = tag.userID;
tag.userID = null;
+ tag.active = false;
await TagStorage.saveTag(tenant, tag);
result.inSuccess++;
// Ensure User has a default Tag

MODIFY
src/types/HTTPError.ts
src/types/HTTPError.ts
@@ -29,6 +29,7 @@ export enum HTTPError {
TAG_ALREADY_EXIST_ERROR = 576,
TAG_VISUAL_ID_ALREADY_EXIST_ERROR = 577,
TAG_VISUAL_ID_DOES_NOT_MATCH_TAG_ERROR = 578,
+ TAG_INACTIVE = 579,
USER_ACCOUNT_LOCKED_ERROR = 590,
USER_ACCOUNT_ALREADY_ACTIVE_ERROR = 591,

Basic user cannot assign inactive tag