Skip to content

feat: add admin KYC review endpoint (closes #59)#68

Merged
ayshadogo merged 2 commits into
Dfunder:mainfrom
shaaibu7:feat/admin-kyc-review
Jun 19, 2026
Merged

feat: add admin KYC review endpoint (closes #59)#68
ayshadogo merged 2 commits into
Dfunder:mainfrom
shaaibu7:feat/admin-kyc-review

Conversation

@shaaibu7

Copy link
Copy Markdown
Contributor

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/:id added to the admin router (already gated by authenticate + isAdmin, so it's admin-only).
  • Validation (reviewKycSchema, Joi): status is required and must be approved or rejected; reviewNote is optional (trimmed, max 1000 chars).
  • Controller (reviewKyc): looks up the user (404 if missing), updates kycStatus and kycReviewNotes, saves, then emails the user. Email sending is non-blocking — the review still succeeds if delivery fails (matching the existing pattern in auth.controller.js).
  • Email template (kycDecision.template.js): approved/rejected HTML variants, styled consistently with the existing welcome/password-reset templates, and includes the reviewer note when present.
  • Tests (admin.kyc.test.js): cover auth required, non-admin rejected, invalid status, 404, approve, and reject.

Reuses the existing User model fields (kycStatus, kycReviewNotes), email.service, and response utilities — no schema changes.

Notes

  • The full Jest suite was not run locally (no network to install dependencies in this environment). All changed files pass node --check, and the tests follow the existing users.kyc.test.js mocking style. Please run npm install && npm test to confirm.

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 ayshadogo left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thank you for your contribution 🤝

@ayshadogo ayshadogo merged commit 336634f into Dfunder:main Jun 19, 2026
1 check passed
@grantfox-oss grantfox-oss Bot mentioned this pull request Jun 19, 2026
5 tasks
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.

Admin: Review and Approve/Reject KYC

2 participants