feat: FORMS-943 Adding file upload component on public form #1644
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
The “File Upload” component is limited to authenticated users. For example, if you create a form that has “Form Access” set to “Public”, then the “File Upload” component is not available when building the form. Probably likewise for BCeID users.
However, you can set the “Form Access” to “IDIR”, create the form and save it, and then set the “Form Access” to “Public”. This is failing and producing 403 errors on the POST because filePermissions.hasFileCreate checks that it’s an IDIR user.
NOTE: some users may be relying on this behaviour. They might want to have a “Staff Only” section of a public form, and it contains components that are only visible to staff after the form is submitted by the public (such as attaching related files to the submission).
This change allows users to:
Create public (anonymous) forms and IDIR upload forms.
Use the file upload component directly on public forms, eliminating the need for workarounds (e.g., switching access levels).
Type of Change
feat (a new feature)
Checklist
Further comments
Have modified the few tests in filepermissions.spec.js file as we are allowing both public and idir users
Modified hasFileCreate middleware to check form settings instead of user types
Verified uploads work in both IDIR-authenticated and public forms