From 5899f31da01f9dbca95bb0eeb1a799a762399d10 Mon Sep 17 00:00:00 2001 From: temi Date: Wed, 1 May 2024 14:25:43 +1000 Subject: [PATCH] AtlasOfLivingAustralia/fieldcapture#3171 - track user in audit messages --- .../services/au/org/ala/ecodata/ParatooService.groovy | 6 ++++++ .../groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy | 3 +++ 2 files changed, 9 insertions(+) diff --git a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy index c0d745bf9..75942f019 100644 --- a/grails-app/services/au/org/ala/ecodata/ParatooService.groovy +++ b/grails-app/services/au/org/ala/ecodata/ParatooService.groovy @@ -228,11 +228,17 @@ class ParatooService { Map authHeader = getAuthHeader() Promise promise = task { + userService.setCurrentUser(userId) asyncFetchCollection(collection, authHeader, userId, project) } promise.onError { Throwable e -> log.error("An error occurred feching ${collection.orgMintedUUID}: ${e.message}", e) + userService.clearCurrentUser() } + promise.onComplete { Map result -> + userService.clearCurrentUser() + } + def result = projectService.update([custom: project.project.custom], project.id, false) [updateResult: result, promise: promise] } diff --git a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy index a57dc2dfe..3bb8f0642 100644 --- a/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy +++ b/src/test/groovy/au/org/ala/ecodata/ParatooServiceSpec.groovy @@ -210,6 +210,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest> [userId: userId] + 1 * userService.setCurrentUser(userId) and: result.updateResult == [status: 'ok'] @@ -297,6 +298,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest> [resp: surveyData] @@ -318,6 +320,7 @@ class ParatooServiceSpec extends MongoSpec implements ServiceUnitTest> [userId: userId] + 1 * userService.setCurrentUser(userId) and: site.name == "SATFLB0001 - Control (100 x 100)"