Skip to content

Sireesha - questionnaire to users invited through the Dropbox process - #2428

Open
kunchalasireesha wants to merge 2 commits into
developmentfrom
sireesha-permanent-questionnaire-link
Open

kunchalasireesha wants to merge 2 commits into
developmentfrom
sireesha-permanent-questionnaire-link

Conversation

@kunchalasireesha

@kunchalasireesha kunchalasireesha commented Oct 24, 2026 •

Copy link
Copy Markdown

Description

Implements: HGN Questionnaire Dashboard – Create a Permanent Questionnaire Link with Access Restrictions.

The frontend adds a permanent, reusable link to the HGN questionnaire (/questionnaire). This PR adds the backend check behind that link: the questionnaire is only available to people who were set up and invited through the HGN Dropbox process (User Profile → Access Management → Dropbox → Invite). The same check now applies when the questionnaire is submitted, so the restriction cannot be bypassed by calling the API directly.

Screenshot 2026-10-24 at 12 38 10 AM

Related PRS (if any):

This backend PR is related to the frontend PR.
To test this backend PR you need to checkout the #XXX frontend PR.
…

Main changes explained:

  • Create src/helpers/questionnaireAccessHelper.js: decides whether a user can open the questionnaire. Eligible means an active user whose applicationAccess record has app: 'dropbox' with status: 'invited', the record the existing Dropbox invite already writes. Owners are always allowed, so they can preview the form.
  • Update src/controllers/hgnFormResponseController.js:
    • Add getAccess, which returns { eligible, reason } for the logged-in user. reason is one of NOT_LOGGED_IN, USER_NOT_FOUND, INACTIVE, NOT_INVITED or ACCESS_REVOKED.
    • submitFormResponse now returns 403 if the user is not eligible, or if a non-Owner submits a response with someone else's user_id.
  • Update src/routes/hgnFormResponseRouter.js: add GET /api/hgnform/access.
  • Add src/helpers/questionnaireAccessHelper.spec.js and update hgnFormResponseController.test.js (new tests for access, the 403 cases, and the new endpoint).
  • Add docs/HGN_QUESTIONNAIRE_LINK.md: onboarding steps and the permanent link, for the onboarding documentation.
    …

How to test:

  1. Check out this branch and the frontend PR branch.
  2. Run npm install and npm run dev here; start the frontend.
  3. Clear site data/cache.
  4. Log in as a volunteer who has not been invited to Dropbox and call GET /api/hgnform/access → expect { "eligible": false, "reason": "NOT_INVITED" }.
  5. As an admin, open that user's profile → Access Management → Dropbox → Invite.
  6. Log in as the user again → GET /api/hgnform/access returns { "eligible": true, ... }.
  7. Submit the questionnaire → 201. Revoke the user's Dropbox access → submitting returns 403.
  8. Log in as an Owner → eligible: true with no Dropbox invite.
  9. Run npx jest src/helpers/questionnaireAccessHelper.spec.js src/controllers/hgnFormResponseController.test.js.

Screenshots or videos of changes:

See the frontend PR OneCommunityGlobal/HighestGoodNetworkApp#5702
for screen recordings
Screenshot 2026-10-24 at 12 54 33 PM

Note:

No schema changes. The check reads the existing applicationAccess collection.

  • Please merge/deploy this before the frontend PR, which calls the new /api/hgnform/access endpoint.
  • docs/ is in .gitignore, so the doc file was force-added (same as docs/BADGE_ASSIGN_API.md).
  • Owner bypass is controlled by BYPASS_ROLES in the helper, in case reviewers prefer no exceptions.

…opbox process

Add GET /api/hgnform/access so the permanent questionnaire link can check
whether the logged-in user was invited to Dropbox, and apply the same check
when submitting the questionnaire. Document the permanent link for onboarding.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Only an invite into the Highest Good Network Team Dropbox folder now unlocks
the HGN Questionnaire. Invites into the Administration Team folder do not.

- Record teamFolderKey on the Dropbox applicationAccess entry when inviting
- Require teamFolderKey 'HGN' in the questionnaire access check, with a new
  NOT_HGN_TEAM_FOLDER reason
- For invites made before teamFolderKey existed, look up the folder in
  Dropbox once and save the key
- Add integration tests (in-memory MongoDB) and team folder lookup tests

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

Copy link
Copy Markdown

This branch has not been deployed

No deployments
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