diff --git a/services/web/app/src/Features/Collaborators/CollaboratorsController.mjs b/services/web/app/src/Features/Collaborators/CollaboratorsController.mjs index 102e9cca28..5c87e901d6 100644 --- a/services/web/app/src/Features/Collaborators/CollaboratorsController.mjs +++ b/services/web/app/src/Features/Collaborators/CollaboratorsController.mjs @@ -122,6 +122,7 @@ async function transferOwnership(req, res, next) { { allowTransferToNonCollaborators: hasAdminAccess(sessionUser), sessionUserId: new ObjectId(sessionUser._id), + ipAddress: req.ip, } ) res.sendStatus(204) diff --git a/services/web/app/src/Features/Collaborators/OwnershipTransferHandler.js b/services/web/app/src/Features/Collaborators/OwnershipTransferHandler.js index b656bc6ce6..82c9c37ac7 100644 --- a/services/web/app/src/Features/Collaborators/OwnershipTransferHandler.js +++ b/services/web/app/src/Features/Collaborators/OwnershipTransferHandler.js @@ -15,7 +15,12 @@ module.exports = { } async function transferOwnership(projectId, newOwnerId, options = {}) { - const { allowTransferToNonCollaborators, sessionUserId, skipEmails } = options + const { + allowTransferToNonCollaborators, + sessionUserId, + skipEmails, + ipAddress, + } = options // Fetch project and user const [project, newOwner] = await Promise.all([ @@ -49,7 +54,7 @@ async function transferOwnership(projectId, newOwnerId, options = {}) { projectId, 'transfer-ownership', sessionUserId, - '', // IP address + ipAddress, { previousOwnerId, newOwnerId } ) diff --git a/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js b/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js index 46dc7eba67..3ef77e3500 100644 --- a/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js +++ b/services/web/test/unit/src/Collaborators/OwnershipTransferHandlerTests.js @@ -261,10 +261,11 @@ describe('OwnershipTransferHandler', function () { it('should write an entry in the audit log', async function () { const sessionUserId = new ObjectId() + const ipAddress = '1.2.3.4' await this.handler.promises.transferOwnership( this.project._id, this.collaborator._id, - { sessionUserId } + { sessionUserId, ipAddress } ) expect( this.ProjectAuditLogHandler.promises.addEntry @@ -272,7 +273,7 @@ describe('OwnershipTransferHandler', function () { this.project._id, 'transfer-ownership', sessionUserId, - '', // IP address + ipAddress, { previousOwnerId: this.user._id, newOwnerId: this.collaborator._id,