From 210a9a7aba902c14dbd1a96095a66ecb0a7c7a52 Mon Sep 17 00:00:00 2001 From: Chamika J <75464293+chamikaJ@users.noreply.github.com> Date: Mon, 4 Aug 2025 15:28:31 +0530 Subject: [PATCH] fix(labels-controller): update color validation to use WorklenzColorShades for label updates - Modified color validation logic in `updateLabel` method to check against `WorklenzColorShades` instead of `WorklenzColorCodes`. - Ensured that the color input is validated correctly during label updates, enhancing data integrity. --- worklenz-backend/src/controllers/labels-controller.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/worklenz-backend/src/controllers/labels-controller.ts b/worklenz-backend/src/controllers/labels-controller.ts index 5e3af115..87d282fc 100644 --- a/worklenz-backend/src/controllers/labels-controller.ts +++ b/worklenz-backend/src/controllers/labels-controller.ts @@ -5,7 +5,7 @@ import db from "../config/db"; import {ServerResponse} from "../models/server-response"; import WorklenzControllerBase from "./worklenz-controller-base"; import HandleExceptions from "../decorators/handle-exceptions"; -import {TASK_PRIORITY_COLOR_ALPHA, WorklenzColorCodes} from "../shared/constants"; +import {TASK_PRIORITY_COLOR_ALPHA, WorklenzColorCodes, WorklenzColorShades} from "../shared/constants"; export default class LabelsController extends WorklenzControllerBase { @HandleExceptions() @@ -73,7 +73,7 @@ export default class LabelsController extends WorklenzControllerBase { WHERE id = $1 AND team_id = $2;`; - if (!WorklenzColorCodes.includes(req.body.color)) + if (!Object.values(WorklenzColorShades).flat().includes(req.body.color)) return res.status(400).send(new ServerResponse(false, null)); const result = await db.query(q, [req.params.id, req.user?.team_id, req.body.color]); @@ -92,7 +92,7 @@ export default class LabelsController extends WorklenzControllerBase { } if (req.body.color) { - if (!WorklenzColorCodes.includes(req.body.color)) + if (!Object.values(WorklenzColorShades).flat().includes(req.body.color)) return res.status(400).send(new ServerResponse(false, null)); updates.push(`color_code = $${paramIndex++}`); values.push(req.body.color);