Reactivate disabled user (Admin only)
POST/company/users/disabled/reactivate/:id
Reactivates a disabled user (restores from soft delete), allowing them to access the platform again.
Objective
Allow administrators to reactivate users who were disabled via soft delete, restoring their full access.
Use Cases
- Reactivate an employee returning to the company
- Restore access disabled by mistake
- Reactivate a user after completing verification
Authentication & Authorization
- Requires a valid JWT (middleware m.isloged)
- Requires admin or dev role (middleware m.isAdmin)
Behavior
- Searches for a user using model.findOneDeleted()
- Restores using user.restore() from mongoose-delete
- Resets status: status = true, reason = NONE
- Clears reasonDate and reasonMessage
- Sets message: User reactivated from disabled status
Process Flow
- Searches for a disabled user by ID
- If not found, returns 404
- Executes user.restore() to revert soft delete
- Sets status = true
- Resets reason = NONE
- Clears reasonDate and reasonMessage
- Saves changes
- Returns the reactivated user
Notes
- This endpoint restores users deleted via soft delete
- Different from POST /status/:id which only changes the status
- Fully recovers the user (removes the deleted flag)
Request
Responses
- 200
- 400
- 401
- 403
- 404
- 500
User successfully reactivated
Invalid request (ID not provided)
Unauthorized (admin or dev role required)
Forbidden (user is not an administrator)
User not found (does not exist or is not disabled).
Error reactivating user