Skip to content

add audit logging for signup action + tests#1680

Merged
evanugarte merged 17 commits intoSCE-Development:devfrom
pxtrickhoxng:audit-on-signup
Jul 1, 2025
Merged

add audit logging for signup action + tests#1680
evanugarte merged 17 commits intoSCE-Development:devfrom
pxtrickhoxng:audit-on-signup

Conversation

@pxtrickhoxng
Copy link
Copy Markdown
Contributor

@pxtrickhoxng pxtrickhoxng commented Jun 9, 2025

Audit logs userId and email at /register endpoint. Added two tests: one verifying audit log functionality, and another to ensure that users are still able to signup even if audit log fails.

#1669 Should be merged first.

Comment thread api/main_endpoints/routes/Auth.js Outdated
userId: user._id,
action: AuditLogActions.SIGN_UP,
details: {email: req.body.email}
});
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.

Suggested change
});
}).catch(logger.error);

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

Comment thread test/api/Auth.js
});
});

describe('/POST login', () => {
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.

i thnk we can move the tests into the below section, we already have it for /POST login

describe('/POST login', () => {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

should already be resolved on most recent commit, [0020286]

Comment thread test/api/Auth.js Outdated
Comment on lines +215 to +218
const auditEntry = await AuditLog.findOne({
action: AuditLogActions.SIGN_UP,
'details.email': registerPayload.email
}).lean();
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.

can we do the below instead, since one document should exist in the collection anyway

Suggested change
const auditEntry = await AuditLog.findOne({
action: AuditLogActions.SIGN_UP,
'details.email': registerPayload.email
}).lean();
const auditEntry = await AuditLog.findOne().lean();

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

done

@evanugarte evanugarte merged commit d61c920 into SCE-Development:dev Jul 1, 2025
4 checks passed
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