Skip to content

fix: allow authenticated users to access /users/status route#2608

Open
AnujChhikara wants to merge 2 commits into
RealDevSquad:developfrom
AnujChhikara:fix/remove-superuser-from-user-status-route
Open

fix: allow authenticated users to access /users/status route#2608
AnujChhikara wants to merge 2 commits into
RealDevSquad:developfrom
AnujChhikara:fix/remove-superuser-from-user-status-route

Conversation

@AnujChhikara

@AnujChhikara AnujChhikara commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Date: 22 Jul , 2026

Developer Name: @AnujChhikara


Issue Ticket Number

  • NA

Tech Doc Link

  • NA

Business Doc Link

  • NA

Description

PR #2599 temporarily restricted GET /users/status to super users (authorizeRoles([SUPERUSER])) to mitigate high Firestore reads on the usersStatus collection, leaving a TODO to revisit whether the route should stay protected.

Since then, we have added pagination to this route and done the query optimization for it (active-users-first, paginated, batched reads), which addressed the high Firestore read concern that motivated the restriction. Because that optimization is now in place, the super_user restriction is no longer needed, so this PR reverts GET /users/status to a normally authenticated route.

  • routes/userStatus.js: GET / now runs authenticate -> validateGetQueryParams -> getUserStatusControllers (dropped authorizeRoles([SUPERUSER])), and removed the obsolete super_user TODO comment.
  • test/integration/userStatus.test.js: switched the GET /users/status tests from the super_user token back to a normal user token so they assert a regular authenticated user can access the route. The unauthorized (401) test is retained.

Note: the super_user restriction on /users/search (also added in #2599) is intentionally left unchanged; this PR scopes only to /users/status.

Documentation Updated?

  • Yes
  • No

Under Feature Flag

  • Yes
  • No

Database Changes

  • Yes
  • No

Breaking Changes

  • Yes
  • No

Development Tested?

  • Yes
  • No

Screenshots

Screenshot 1 image image

Test Coverage

Screenshot 1 image

Additional Notes

Removes the super_user role restriction from the GET /users/status
route so any authenticated user can access it, using the standard
authenticate middleware instead of authorizeRoles([SUPERUSER]).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown

Review Change Stack

Walkthrough

The user status GET route now requires authentication and query validation, but no longer restricts access to SUPERUSER users.

Changes

User status access control

Layer / File(s) Summary
Update user status middleware
routes/userStatus.js
Removes authorizeRoles([SUPERUSER]) from the GET route while retaining authentication, query validation, and controller execution.

Estimated code review effort: 1 (Trivial) | ~2 minutes

Possibly related PRs

Poem

A bunny hops past the guarded door,
Auth still checks, but roles no more.
Queries validated, status in sight,
The route now welcomes a wider light. 🐇

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly describes the main change: removing the superuser restriction from the /users/status route.
Description check ✅ Passed The description is directly related to the changes and accurately explains the route and test updates.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

Comment thread routes/userStatus.js Dismissed
Switch the GET /users/status integration tests from the super_user token
back to a normal user token, matching the reverted route which now only
requires authentication. The unauthorized (401) test is retained.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@AnujChhikara AnujChhikara self-assigned this Jul 22, 2026
Comment thread routes/userStatus.js
// TODO: Have a discussion, if this 'users/status' needs to be open or protected.
// For now making it protected and super_user only to sort the high firestore read issues, for usersStatus collection
router.get("/", authenticate, authorizeRoles([SUPERUSER]), validateGetQueryParams, getUserStatusControllers);
router.get("/", authenticate, validateGetQueryParams, getUserStatusControllers);

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.

Is this used in by any of the other services, where we might have to look into it?

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.

3 participants