feat: add admin KYC review endpoint (closes #59)#68
Merged
Conversation
Add PATCH /api/admin/kyc/:id for admins to review KYC submissions. - Requires authentication and admin role (reuses existing middleware) - Validates body with Joi: status (approved|rejected) required, optional reviewNote - Updates the user's kycStatus and kycReviewNotes - Emails the user about the decision via a new KYC decision template (non-blocking so the review still succeeds if email delivery fails) - Adds tests covering auth, role, validation, 404, approve and reject
ayshadogo
approved these changes
Jun 19, 2026
ayshadogo
left a comment
Contributor
There was a problem hiding this comment.
Thank you for your contribution 🤝
5 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds an admin-only endpoint that lets admins review KYC submissions and update their status, notifying the user of the decision by email.
Closes #59
Changes
PATCH /api/admin/kyc/:idadded to the admin router (already gated byauthenticate+isAdmin, so it's admin-only).reviewKycSchema, Joi):statusis required and must beapprovedorrejected;reviewNoteis optional (trimmed, max 1000 chars).reviewKyc): looks up the user (404 if missing), updateskycStatusandkycReviewNotes, saves, then emails the user. Email sending is non-blocking — the review still succeeds if delivery fails (matching the existing pattern inauth.controller.js).kycDecision.template.js): approved/rejected HTML variants, styled consistently with the existing welcome/password-reset templates, and includes the reviewer note when present.admin.kyc.test.js): cover auth required, non-admin rejected, invalid status, 404, approve, and reject.Reuses the existing
Usermodel fields (kycStatus,kycReviewNotes),email.service, andresponseutilities — no schema changes.Notes
node --check, and the tests follow the existingusers.kyc.test.jsmocking style. Please runnpm install && npm testto confirm.