Skip to content

Diya fix(userStatus): Fixed User Lifecycle Issues#2212

Open
DiyaWadhwani wants to merge 2 commits into
developmentfrom
Diya_Fix_UserLifecycleFlow
Open

Diya fix(userStatus): Fixed User Lifecycle Issues#2212
DiyaWadhwani wants to merge 2 commits into
developmentfrom
Diya_Fix_UserLifecycleFlow

Conversation

@DiyaWadhwani
Copy link
Copy Markdown
Contributor

@DiyaWadhwani DiyaWadhwani commented May 13, 2026

Description

Fixes the backend user lifecycle status management flow — specifically a 500 error on immediate deactivation, missing field projections, stale cache after reactivation, and restores lifecycle email handlers that were removed by a previous unidentified PR.
Fixes # (High) — User deactivation/reactivation/pause lifecycle flow

Related PRS (if any):

This backend PR is related to the frontend PR #5264.

Main changes explained:

  • Update userProfileController.js — add deactivatedAt to the findById projection in changeUserStatus. This field was missing from the projection but being assigned in the DEACTIVATE case, causing Mongoose to throw a validation error on user.save() which returned an empty {} 500 response.
  • Update userProfileController.js — fix the catch block in changeUserStatus to return { message, name } instead of the raw error object, which serializes to {} and makes debugging impossible.
  • Update userProfileController.js — fix handleUserStatusSave to clear reactivationDate and endDate in the allusers cache when the action is ACTIVATE, so getAllUserProfile does not return stale lifecycle fields after reactivation.
  • Update userProfileController.js — restore lifecycle email handlers for pause, separation, scheduled separation, reactivation, and final day cancellation that were removed by a previous PR. These handlers are called inside handleUserStatusSave and are required for notifying users and admins of status changes.

How to test:

Follow frontend PR for testing instructions.

@sonarqubecloud
Copy link
Copy Markdown

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.

1 participant