Skip to content

feat: admin suspend/activate user account (#58)#67

Merged
ayshadogo merged 2 commits into
Dfunder:mainfrom
MarcusDavidG:feat/admin-suspend-activate-user
Jun 19, 2026
Merged

feat: admin suspend/activate user account (#58)#67
ayshadogo merged 2 commits into
Dfunder:mainfrom
MarcusDavidG:feat/admin-suspend-activate-user

Conversation

@MarcusDavidG

Copy link
Copy Markdown
Contributor

Summary

Closes #58

Changes

  • User model: Added status field with enum ['active', 'suspended'], defaulting to 'active'
  • Login: Suspended users are blocked at login with a 403 and message: "Your account has been suspended. Please contact support."
  • New endpoint: PATCH /api/admin/users/:id/status — requires admin role, accepts { status: 'active' | 'suspended' }
  • Tests: 7 tests covering suspend, reactivate, invalid status, 404, self-status change prevention, auth guard, and suspended login

Endpoint

PATCH /api/admin/users/:id/status
Authorization: Bearer <admin-token>
Body: { "status": "suspended" | "active" }

Acceptance Criteria

  • Suspended users cannot log in and receive 403 with a clear message
  • Admins can suspend or reactivate any user except themselves
  • Endpoint is protected by admin role middleware

MarcusDavidG and others added 2 commits June 19, 2026 06:11
- Add status field (active | suspended) to User model
- Add PATCH /api/admin/users/:id/status endpoint (admin only)
- Block suspended users from logging in with 403 response
- Add tests for status endpoint and suspended user login

@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 d9d0b3a into Dfunder:main Jun 19, 2026
1 check 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.

Admin: Suspend or Activate User Account

2 participants