Skip to content

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

Closed
shaaibu7 wants to merge 76 commits into
SudiptaPaul-31:mainfrom
shaaibu7:feat/admin-kyc-review
Closed

feat: add admin KYC review endpoint (closes #59)#1
shaaibu7 wants to merge 76 commits into
SudiptaPaul-31:mainfrom
shaaibu7:feat/admin-kyc-review

Conversation

@shaaibu7

Copy link
Copy Markdown

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 Merzher#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.

SudiptaPaul-31 and others added 30 commits March 1, 2026 18:41
- Install and configure cors middleware
- Restrict allowed origins to ALLOWED_ORIGINS env variable (comma-separated)
- Allow methods: GET, POST, PUT, PATCH, DELETE
- Allow headers: Authorization, Content-Type
- Requests from disallowed origins will receive a CORS error

Configure CORS Policy
Fixes Merzher#6
Created src/middlewares/validate.js for validating req.body against Joi schemas
- Returned 400 Bad Request with structured field-level errors on validation failure
- Added example validators in src/validators/auth.validators.js (register/login schemas)
…sted-origins

feat: configure CORS middleware for trusted origins
feat: add reusable Joi request validation middleware, closes Merzher#3
Setup CI/CD Pipeline to Run Linting, Tests, and Build
Configure-Environment-Variables-Setup-Global-Error-Handling-Middleware
set up the npm run lint  to check for errors
…iables-Setup-Global-Error-Handling-Middleware

Configure-Environment-Variables-Setup-Global-Error-Handling-Middleware
…ility-Helper

feat: Add API Response Utility Helper
…tility

- Create logger utility (src/utils/logger.js) with stream interface for Morgan
- Update Morgan configuration to use dev format in development and combined format in production
- Stream Morgan output through custom logger using console.log
- All acceptance criteria met: environment-aware formats, custom logger, Morgan integration, quality checks pass
feat(logging): add HTTP request logging with morgan for dev and production environments (Merzher#5)
…point

The User Registration endpoint has been created accordingly
feat(auth): implement login endpoint with JWT tokens
ayshadogo and others added 28 commits March 5, 2026 12:48
…t-password-endpoint

feat: implement forgot password endpoint
…n-middleware

Implement the role-based authorization middleware and set up the infrastructure for admin-exclusive routes
Implement-Token-Refresh-Endpoin
…d-Endpoint-#28

feat:Add Change Password Endpoint Merzher#28
)

- Add deletedAt field to User model for soft delete
- Add Mongoose middleware to exclude deleted users from queries
- Create DELETE /api/admin/users/:id endpoint
- Add isAdmin middleware for role verification
- Prevent admins from deleting their own account
- Add restore endpoint for soft-deleted users
- Install multer for file upload handling
- Add avatar field to User model to store file path
- Create POST /api/users/me/avatar endpoint for profile picture uploads
- Implement file validation: only JPEG/PNG, max 2MB
- Add static file serving to make avatars accessible
- Auto-delete old avatars when new ones are uploaded
- Add uploads directory to .gitignore
…61-admin-delete-user

feat: add admin delete user endpoint with soft delete (Closes Merzher#61)
feat: add user profile picture upload functionality
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
@shaaibu7

Copy link
Copy Markdown
Author

Closing — opened against the wrong upstream by mistake. Reopened on Merzher#68.

@shaaibu7 shaaibu7 closed this Jun 19, 2026
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