Skip to content

Implement audit log on user edit + tests#1730

Merged
evanugarte merged 5 commits into
SCE-Development:devfrom
pxtrickhoxng:audit-on-user-update
Jul 5, 2025
Merged

Implement audit log on user edit + tests#1730
evanugarte merged 5 commits into
SCE-Development:devfrom
pxtrickhoxng:audit-on-user-update

Conversation

@pxtrickhoxng

Copy link
Copy Markdown
Contributor

Add an audit log for when a user is updated.

Comment thread api/main_endpoints/routes/User.js Outdated
userId: decoded._id, // the user making the update
action: AuditLogActions.UPDATE_USER,
documentId: user._id, // the user affected by the update
details: {updatedInfo: user}

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • edit a user, change their password
  • does the password field appear in the AuditLog collection?
  • if so, lets add logic to replace password to true, if it is set, so we avoid storing it

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

add a unit test to verify this as well

@pxtrickhoxng
pxtrickhoxng force-pushed the audit-on-user-update branch from 2e7e14d to 85d37fb Compare July 1, 2025 04:42
Comment thread test/api/User.js Outdated
await AuditLog.deleteMany({});
});

it('Should create an audit log when a user is updated', async () => {

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this could probably be one test? since they both test the same thing except for one extra assertion

@evanugarte
evanugarte merged commit 10a2db1 into SCE-Development:dev Jul 5, 2025
4 checks passed
aeiouny pushed a commit to aeiouny/Clark that referenced this pull request Jul 7, 2025
* Implement audit log on user edit + tests

* update tests to send user data alongside token

* ensures user's password isn't stored in audit log

* combine unit tests on user edit audit log
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants