From 0b3f67abae7c6c3f9a9412e5417c876ac736655c Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 6 Feb 2023 08:01:37 -0500 Subject: [PATCH 1/2] When searching for human tasks to determine if the current user can complete it, filter on the "completed" flag. Front-end -- enable the form if you receive an onUnathorized error because the thing you are unauthorized to do might have nothing to do with whether you can submit the form. --- .../spiffworkflow_backend/services/authorization_service.py | 1 + spiffworkflow-frontend/src/routes/TaskShow.tsx | 6 ++++-- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py index a72effd46..db3c3cced 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py @@ -457,6 +457,7 @@ class AuthorizationService: human_task = HumanTaskModel.query.filter_by( task_name=spiff_task.task_spec.name, process_instance_id=process_instance_id, + completed=False ).first() if human_task is None: raise HumanTaskNotFoundError( diff --git a/spiffworkflow-frontend/src/routes/TaskShow.tsx b/spiffworkflow-frontend/src/routes/TaskShow.tsx index 93100a288..948bafb73 100644 --- a/spiffworkflow-frontend/src/routes/TaskShow.tsx +++ b/spiffworkflow-frontend/src/routes/TaskShow.tsx @@ -42,9 +42,12 @@ export default function TaskShow() { HttpService.makeCallToBackend({ path: url, successCallback: (tasks: any) => { + setDisabled(false); setUserTasks(tasks); }, - onUnauthorized: () => {}, + onUnauthorized: () => { + setDisabled(false); + }, failureCallback: (error: any) => { addError(error); }, @@ -61,7 +64,6 @@ export default function TaskShow() { const processSubmitResult = (result: any) => { removeError(); - setDisabled(false); if (result.ok) { navigate(`/tasks`); } else if (result.process_instance_id) { From c7438253c74e114dce821818a206b24d0a0de840 Mon Sep 17 00:00:00 2001 From: Dan Date: Mon, 6 Feb 2023 08:05:33 -0500 Subject: [PATCH 2/2] run_pyl --- .../src/spiffworkflow_backend/services/authorization_service.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py index db3c3cced..2491d44f4 100644 --- a/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py +++ b/spiffworkflow-backend/src/spiffworkflow_backend/services/authorization_service.py @@ -457,7 +457,7 @@ class AuthorizationService: human_task = HumanTaskModel.query.filter_by( task_name=spiff_task.task_spec.name, process_instance_id=process_instance_id, - completed=False + completed=False, ).first() if human_task is None: raise HumanTaskNotFoundError(