Skip to content

Sai Teja - Add backend support for dedicated pause/resume permission#2161

Open
saitejakaasoju wants to merge 5 commits intoOneCommunityGlobal:developmentfrom
saitejakaasoju:sai/pause-user-permission-backend
Open

Sai Teja - Add backend support for dedicated pause/resume permission#2161
saitejakaasoju wants to merge 5 commits intoOneCommunityGlobal:developmentfrom
saitejakaasoju:sai/pause-user-permission-backend

Conversation

@saitejakaasoju
Copy link
Copy Markdown

Description

Implements backend support for the dedicated pause/resume permission flow.

This PR adds support for the interactWithPauseUserButton permission in backend authorization logic, adds a dedicated pause/resume route, and seeds the permission into the expected default roles.

Fixes priority high bug(s):

  • Pause requests returning 404 because the dedicated pause route was missing
  • Pause/resume authorization using stale or inconsistent permission checks
  • Admin/Owner default permissions not including the new pause interaction permission

Related PRs (if any):

This backend PR is related to the frontend PR:

  • HighestGoodNetworkApp PR: sai/pause-user-permission

To fully test this backend PR, you need to run the matching frontend PR as well.

Main changes explained:

  • Update src/routes/userProfileRouter.js to add:
    • PATCH /api/userProfile/:userId/pause
  • Update src/controllers/userProfileController.js to:
    • add dedicated pauseResumeUser controller logic
    • authorize pause/resume using interactWithPauseUserButton
    • allow the new permission in related user status authorization checks
    • allow users with this permission to access the needed user profile list flow
  • Update src/utilities/createInitialPermissions.js to seed interactWithPauseUserButton into:
    • Administrator
    • Owner

How to test:

  1. Check out this branch in HGNRest
  2. Run the matching frontend PR locally from HighestGoodNetworkApp
  3. Start the backend from this branch
  4. Log in through the frontend as an Owner or Administrator with interactWithPauseUserButton
  5. Pause a user from the profile page and verify:
    • request succeeds
    • user becomes inactive / paused
  6. Resume that paused user and verify:
    • request succeeds
    • user becomes active again
  7. Verify the User Management table pause/resume flow also works
  8. Remove the permission from a test Owner/Admin and verify the frontend no longer exposes pause controls
  9. Grant the permission to a non-admin user and verify the backend accepts pause/resume requests from that user
  10. Confirm the paused user cannot log in until reactivated

Screenshots or videos of changes:

Note:

This PR should be tested together with the matching frontend PR. The frontend now uses the dedicated pause endpoint and the new permission key consistently.

Saiteja1703 and others added 5 commits February 25, 2026 12:19
…s dashboard

Changed logical operator from || to && in permission checks for
getUserNotifications and getUnreadUserNotifications in notificationController.js.

The previous condition (role !== 'Administrator' || role !== 'Owner') was
always true, blocking Admins and Owners from accessing another user's
notification data and causing a 'You are forbidden to access the resource'
popup when viewing other dashboards or clicking a user in the Leaderboard.

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
…ssion logic

Updated test cases for getUserNotifications and getUnreadUserNotifications
to correctly reflect the fixed || to && permission check.

- Updated 403 test to use a non-Admin/non-Owner role (Volunteer)
- Added new tests to verify Admins and Owners can access other users' notifications

Co-Authored-By: Claude Sonnet 4.6 <[email protected]>
@sonarqubecloud
Copy link
Copy Markdown

sonarqubecloud bot commented Apr 9, 2026

Quality Gate Failed Quality Gate failed

Failed conditions
30.7% Duplication on New Code (required ≤ 3%)
B Security Rating on New Code (required ≥ A)

See analysis details on SonarQube Cloud

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE

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.

2 participants