Skip to content

Aditya - Job Application Listing Page: allow public read access to the FAQ list - #2324

Open
AdiDubbs wants to merge 1 commit into
developmentfrom
Aditya_fix_public_faq_endpoint
Open

Aditya - Job Application Listing Page: allow public read access to the FAQ list#2324
AdiDubbs wants to merge 1 commit into
developmentfrom
Aditya_fix_public_faq_endpoint

Conversation

@AdiDubbs

@AdiDubbs AdiDubbs commented Aug 28, 2026

Copy link
Copy Markdown

Description

The job listing page at /collaboration is public - it does not require signing in. Its FAQ section reads from GET /faqs, which required a token, so a signed-out visitor received a 401 and got an error where the FAQs should be. This PR makes the changes to allow public read access to the FAQ list

This issue concerns Item 33.

Screenshot 2026-08-27 at 8 18 25 PM

Related PRS (if any):

Frontend: OneCommunityGlobal/HighestGoodNetworkApp#5473

Main changes explained:

  1. Added GET /api/faqs to the global auth allowlist in startup/middleware.js. That app.all('*') gate runs before every route, so removing the router's own guard alone had no effect. It is matched on req.path exactly rather than as a prefix, so the search, history, unanswered and write routes are untouched.
  2. Removed verifyToken from the /faqs route in faqRouter.js. getAllFAQs does not read req.user, so nothing in the handler depended on it.

GET /api/jobs is already public in the same allowlist — that is how the job listing itself loads for visitors — so this follows the existing pattern for this page.

How to test:

  1. Check out this branch and run npm install
  2. Start Redis: redis-server --daemonize yes
  3. Run npm run dev
  4. Confirm the FAQ list is now public, and that nothing else opened up:
curl -o /dev/null -w "%{http_code}\n" http://localhost:4500/api/faqs              # 200
curl -o /dev/null -w "%{http_code}\n" "http://localhost:4500/api/faqs/search?q=a" # 401
curl -o /dev/null -w "%{http_code}\n" http://localhost:4500/api/faqs/unanswered   # 401
curl -o /dev/null -w "%{http_code}\n" http://localhost:4500/api/faqs/123/history  # 401
curl -o /dev/null -w "%{http_code}\n" -X POST -H "Content-Type: application/json" -d '{}' http://localhost:4500/api/faqs   # 401
curl -o /dev/null -w "%{http_code}\n" -X DELETE http://localhost:4500/api/faqs/123 # 401
  1. Signed in, confirm /api/faqs, /api/faqs/search and /api/faqs/unanswered all return 200 as before — authenticated access is unchanged.
  2. Run npm run lint

Note:

Not addressed here, found while testing:

  • GET /faqs/unanswered and DELETE /faqs/unanswered/:id check only for a token, not for manageFAQs, unlike the other management endpoints. The UI hides that page behind the permission, but any signed-in user can call those endpoints directly. Raised separately rather than mixed into this change.

The job listing page at /collaboration is reachable without signing in, and
its FAQ section reads from GET /faqs. Opens that one route in the global
auth allowlist and drops its verifyToken guard. Matched on the exact path so
the search, history, unanswered and write routes stay authenticated.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@sonarqubecloud

Copy link
Copy Markdown

@AdiDubbs
AdiDubbs marked this pull request as ready for review August 30, 2026 03:12
@one-community one-community added the High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible label Sep 1, 2026

@DeMoliT1on DeMoliT1on left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tested locally for backend PR changes branch Aditya_fix_public_faq_endpoint and observed the following things.


Overall Assessment

Verified Working

  • Public FAQ Endpoint: GET /api/faqs successfully returns a 200 OK status without an Authorization header.
  • Protected FAQ Sub-routes: Routes requiring authentication (e.g., GET /api/faqs/search) correctly return 401 Unauthorized when requested without a valid token.
  • Authenticated Access Preserved: Requests to protected endpoints with a valid JWT token continue to return 200 OK as expected.

Screenshots

Image Image Image

The implementation accurately opens public access strictly for GET /api/faqs while keeping administrative and sub-routes securely protected.
Approved!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

High Priority - Please Review First This is an important PR we'd like to get merged as soon as possible

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants