mirror of
https://github.com/yu-i-i/overleaf-cep.git
synced 2026-05-23 17:19:37 +02:00
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:
@@ -122,6 +122,7 @@ async function transferOwnership(req, res, next) {
|
||||
{
|
||||
allowTransferToNonCollaborators: hasAdminAccess(sessionUser),
|
||||
sessionUserId: new ObjectId(sessionUser._id),
|
||||
ipAddress: req.ip,
|
||||
}
|
||||
)
|
||||
res.sendStatus(204)
|
||||
|
||||
@@ -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 }
|
||||
)
|
||||
|
||||
|
||||
@@ -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,
|
||||
|
||||
Reference in New Issue
Block a user