Expose overrideAccess
to collection/fields hooks
#8777
Fitch24
started this conversation in
Feature Requests & Ideas
Replies: 1 comment 1 reply
-
@Fitch24 let me make your life easier! The fields that Payload adds for you are configurable. When adding your own with the same name as a builtin field, Payload will use your field instead of adding another with the same name. This works for createdAt, updatedAt and email for auth collections. This should be in the docs somewhere if it isn't already. Let me know how it goes. |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Sometimes is not possible to configure access for the field, so we need to protect (hide/remove) this fields in collection hooks (
afterRead
/beforeChange
). For example, we can't configure access totimestamp
fields (to hide or protect from editing by non-admins), oremail
field inauth
collections (if need to hide user email from other users). So access for this fields can be handled in collection hooks, but this hooks will be invoked in local API and we can't skip this hooks by passingoverrideAccess: true
. ExposingoverrideAcces
to hooks can solve this problem by adding a check in hook code to do nothing ifoverrideAccess
istrue
.Example of possible use:
For now, I use request
context
to skip this hooks, but it's require to passoverrideAccess
twice:It can produce errors, if I forgot to add
overrideAccess
tocontext
Beta Was this translation helpful? Give feedback.
All reactions