Skip to content

Commit 0789f4d

Browse files
authored
fix(plugin-form-builder)!: emails array field has read access by authenticated users only by default now (#8338)
1 parent cb83136 commit 0789f4d

File tree

2 files changed

+8
-1
lines changed

2 files changed

+8
-1
lines changed

docs/plugins/form-builder.mdx

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,14 +154,18 @@ Override anything on the `forms` collection by sending a [Payload Collection Con
154154

155155
Note that the `fields` property is a function that receives the default fields and returns an array of fields. This is because the `fields` property is a special case that is merged with the default fields, rather than replacing them. This allows you to map over default fields and modify them as needed.
156156

157+
<Banner type="warning">
158+
Good to know: The form collection is publicly available to read by default. The emails field is locked for authenticated users only. If you have any frontend users you should override the access permissions for both the collection and the emails field to make sure you don't leak out any private emails.
159+
</Banner>
160+
157161
```ts
158162
// payload.config.ts
159163
formBuilder({
160164
// ...
161165
formOverrides: {
162166
slug: 'contact-forms',
163167
access: {
164-
read: () => true,
168+
read: ({ req: { user } }) => !!user, // authenticated users only
165169
update: () => false,
166170
},
167171
fields: ({ defaultFields }) => {

packages/plugin-form-builder/src/collections/Forms/index.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,9 @@ export const generateFormCollection = (formConfig: FormBuilderPluginConfig): Col
138138
{
139139
name: 'emails',
140140
type: 'array',
141+
access: {
142+
read: ({ req: { user } }) => !!user,
143+
},
141144
admin: {
142145
description:
143146
"Send custom emails when the form submits. Use comma separated lists to send the same email to multiple recipients. To reference a value from this form, wrap that field's name with double curly brackets, i.e. {{firstName}}. You can use a wildcard {{*}} to output all data and {{*:table}} to format it as an HTML table in the email.",

0 commit comments

Comments
 (0)