Merge pull request #24181 from overleaf/bg-Project-Audit-Log-Transfer-ownership-is-missing-the-IP-address

add missing ip adress to audit log for transfer ownership

GitOrigin-RevId: c14494efce25efa92a6cd81bcf197d8f897571bb
This commit is contained in:
Brian Gough
2025-03-11 08:59:17 +00:00
committed by Copybot
parent aaa15a2733
commit a04d3198a8
3 changed files with 11 additions and 4 deletions

View File

@@ -122,6 +122,7 @@ async function transferOwnership(req, res, next) {
{
allowTransferToNonCollaborators: hasAdminAccess(sessionUser),
sessionUserId: new ObjectId(sessionUser._id),
ipAddress: req.ip,
}
)
res.sendStatus(204)

View File

@@ -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 }
)

View File

@@ -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,