Files
payloadcms/docs/access-control/globals.mdx
2021-02-04 11:36:09 -05:00

52 lines
1.5 KiB
Plaintext

---
title: Globals Access Control
label: Globals
order: 40
desc: Global-level Access Control is specified within each Global's `access` property and allows you to define which users can read or update Globals.
keywords: globals, access control, permissions, documentation, Content Management System, cms, headless, javascript, node, react, express
---
You can define Global-level Access Control within each Global's `access` property. All Access Control functions accept one `args` argument.
**Available argument properties:
## Available Controls
| Function | Allows/Denies Access |
| ------------------------ | -------------------- |
| **[`read`](#read)** | Used in the `findOne` Global operation |
| **[`update`](#update)** | Used in the `update` Global operation |
**Example Global config:**
```js
export default {
slug: "header",
// highlight-start
access: {
read: ({ req: { user } }) => { ... },
update: ({ req: { user } }) => { ... },
},
// highlight-end
};
```
### Read
Returns a boolean result to allow or deny a user's ability to read the Global.
**Available argument properties:**
| Option | Description |
| --------- | ----------- |
| **`req`** | The Express `request` object containing the currently authenticated `user` |
### Update
Returns a boolean result to allow or deny a user's ability to update the Global.
**Available argument properties:**
| Option | Description |
| --------- | ----------- |
| **`req`** | The Express `request` object containing the currently authenticated `user` |