From 971891dd6b68dd3ef2ff9759231377394dcac1b4 Mon Sep 17 00:00:00 2001 From: SabreCat Date: Tue, 23 Aug 2022 10:48:21 -0500 Subject: [PATCH] fix(tasks): no really, address not-found error --- website/server/controllers/api-v3/tasks/groups.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/website/server/controllers/api-v3/tasks/groups.js b/website/server/controllers/api-v3/tasks/groups.js index 8d0c671421..963fcdbf91 100644 --- a/website/server/controllers/api-v3/tasks/groups.js +++ b/website/server/controllers/api-v3/tasks/groups.js @@ -356,11 +356,13 @@ api.taskNeedsWork = { if (['daily', 'todo'].indexOf(task.type) === -1) { throw new BadRequest('Cannot roll back use of Habits or Rewards.'); } - if (!task.group.assignedUsersDetail) task.group.assignedUsersDetail = {}; - if ( - (task.group.completedBy.userId && task.group.completedBy.userId !== assignedUserId) - || !(task.group.assignedUsersDetail[assignedUserId] - && task.group.assignedUsersDetail[assignedUserId].completed)) { + + if (task.group.completedBy.userId) { + if (task.group.completedBy.userId !== assignedUserId) { + throw new BadRequest('Task not completed by this user.'); + } + } else if (!task.group.assignedUsersDetail || !task.group.assignedUsersDetail[assignedUserId] + || !task.group.assignedUsersDetail[assignedUserId].completed) { throw new BadRequest('Task not completed by this user.'); }