Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
90 commits
Select commit Hold shift + click to select a range
4e2f256
chore: add section for design contributions in contributing.md
AlessioGr Aug 15, 2023
6d6acbc
Merge pull request #3176 from payloadcms/chore/docs-design-contributions
AlessioGr Aug 15, 2023
33686c6
feat: add afterOperation hook (#2697)
stefgootzen Aug 15, 2023
c154eb7
chore: remove swc version pin (#3179)
JarrodMFlesch Aug 15, 2023
fdfdfc8
fix: WhereBuilder component does not accept all valid Where queries (…
AlessioGr Aug 15, 2023
20b6b29
chore(test): adds test to ensure relationship returns over 10 docs (#…
JessRynkar Aug 15, 2023
7963d04
fix: passes in height to resizeOptions upload option to allow height …
PatrikKozak Aug 15, 2023
8d83e05
docs: fixes syntax error in rich-text.mdx that was breaking build
jacobsfletch Aug 16, 2023
960fbac
chore(deps): bump semver in /examples/redirects/nextjs
dependabot[bot] Aug 16, 2023
87cc01a
chore(deps): bump word-wrap in /examples/redirects/nextjs
dependabot[bot] Aug 16, 2023
8464853
docs: removes auto-formatting from rich-text.mdx (#3188)
jacobsfletch Aug 16, 2023
e03a8e6
feat: Improve admin dashboard accessibility (#3053)
r3pwn Aug 16, 2023
d91b44c
feat: improve field ops (#3172)
jmikrut Aug 16, 2023
0acd7b8
chore: file cleanup (#3190)
JarrodMFlesch Aug 16, 2023
f5f2332
chore(release): v1.14.0
DanRibbens Aug 16, 2023
294fb5e
chore: improve ts typing in sanitization functions (#3194)
JarrodMFlesch Aug 17, 2023
3634e2c
chore(templates): default port on website
denolfe Aug 17, 2023
81b4e86
Merge pull request #1 from NastyApplication/dependabot/npm_and_yarn/e…
NikolaRHristov Aug 17, 2023
9b22265
Merge pull request #2 from NastyApplication/dependabot/npm_and_yarn/e…
NikolaRHristov Aug 17, 2023
667e6b4
chore(deps): bump word-wrap in /examples/form-builder/nextjs
dependabot[bot] Aug 17, 2023
2cb5735
Merge pull request #3 from NastyApplication/dependabot/npm_and_yarn/e…
NikolaRHristov Aug 17, 2023
31b79fd
Merge branch 'payloadcms:master' into master
NikolaRHristov Aug 20, 2023
b0b1ae1
chore(deps): bump @adobe/css-tools from 4.3.0 to 4.3.1
dependabot[bot] Aug 30, 2023
59ac01b
Merge pull request #4 from NastyApplication/dependabot/npm_and_yarn/a…
NikolaRHristov Aug 30, 2023
78b9249
chore(deps): bump graphql in /examples/form-builder/nextjs
dependabot[bot] Sep 21, 2023
bb81a37
chore(deps): bump graphql from 16.7.1 to 16.8.1 in /templates/blank
dependabot[bot] Sep 21, 2023
4a85f6e
chore(deps): bump graphql in /examples/multi-tenant
dependabot[bot] Sep 21, 2023
9d615e3
chore(deps): bump graphql from 16.7.1 to 16.8.1 in /examples/whitelabel
dependabot[bot] Sep 21, 2023
9da37ac
chore(deps): bump graphql in /examples/auth/payload
dependabot[bot] Sep 21, 2023
4bf7d39
chore(deps): bump graphql in /examples/redirects/cms
dependabot[bot] Sep 21, 2023
9eb7ccb
chore(deps): bump graphql from 16.7.1 to 16.8.1
dependabot[bot] Sep 21, 2023
f3623bb
chore(deps): bump graphql in /examples/draft-preview/payload
dependabot[bot] Sep 21, 2023
28f3442
Merge pull request #17 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Sep 22, 2023
2be0363
Merge pull request #15 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Sep 22, 2023
c1941b8
Merge pull request #13 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Sep 22, 2023
9de941f
Merge pull request #12 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Sep 22, 2023
7de3596
Merge pull request #11 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Sep 22, 2023
c0e7619
chore(deps): bump graphql in /examples/custom-server
dependabot[bot] Sep 22, 2023
1813d7b
chore(deps): bump graphql from 16.7.1 to 16.8.1 in /templates/ecommerce
dependabot[bot] Sep 22, 2023
b8f3b4a
Merge pull request #10 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Sep 22, 2023
e82c418
Merge pull request #9 from NastyApplication/dependabot/npm_and_yarn/e…
NikolaRHristov Sep 22, 2023
8504970
chore(deps): bump graphql from 16.7.1 to 16.8.1 in /templates/website
dependabot[bot] Sep 22, 2023
0ff6067
Merge pull request #8 from NastyApplication/dependabot/npm_and_yarn/t…
NikolaRHristov Sep 22, 2023
18b8a29
Merge pull request #7 from NastyApplication/dependabot/npm_and_yarn/t…
NikolaRHristov Sep 22, 2023
d9f18f7
chore(deps): bump graphql from 16.7.1 to 16.8.1 in /examples/email
dependabot[bot] Sep 22, 2023
656ca66
Merge pull request #6 from NastyApplication/dependabot/npm_and_yarn/t…
NikolaRHristov Sep 22, 2023
515aa51
Merge pull request #5 from NastyApplication/dependabot/npm_and_yarn/e…
NikolaRHristov Sep 22, 2023
f3afe5a
chore(deps): bump graphql in /examples/form-builder/cms
dependabot[bot] Sep 22, 2023
c358d8e
Merge pull request #16 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Sep 22, 2023
4882f8b
Merge pull request #14 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Sep 22, 2023
33e5832
chore(deps): bump postcss in /examples/draft-preview/payload
dependabot[bot] Oct 8, 2023
e22636f
chore(deps): bump postcss from 8.4.27 to 8.4.31 in /templates/website
dependabot[bot] Oct 8, 2023
bfe2f60
chore(deps): bump postcss from 8.4.27 to 8.4.31 in /examples/email
dependabot[bot] Oct 8, 2023
f113c83
chore(deps): bump postcss from 8.4.27 to 8.4.31 in /templates/blank
dependabot[bot] Oct 8, 2023
84a1393
chore(deps): bump postcss from 8.4.27 to 8.4.31
dependabot[bot] Oct 8, 2023
15a9429
chore(deps): bump postcss in /examples/form-builder/cms
dependabot[bot] Oct 8, 2023
e3a4d29
chore(deps): bump postcss in /examples/auth/payload
dependabot[bot] Oct 8, 2023
621c86a
Merge pull request #27 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
c5522f4
Merge pull request #26 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
04dd32d
Merge pull request #25 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
87a7bf2
Merge pull request #24 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
a7eb735
Merge pull request #23 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
16ee4c4
Merge pull request #22 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
85ad348
chore(deps): bump postcss from 8.4.27 to 8.4.31 in /examples/whitelabel
dependabot[bot] Oct 8, 2023
72896df
Merge pull request #20 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
81b4b44
chore(deps): bump postcss in /examples/redirects/cms
dependabot[bot] Oct 8, 2023
16307a8
Merge pull request #19 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
3dc7329
chore(deps): bump postcss in /examples/multi-tenant
dependabot[bot] Oct 8, 2023
03ca703
Merge pull request #18 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
99a5fd5
Merge pull request #21 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 8, 2023
8dd1614
chore(deps): bump @babel/traverse from 7.22.10 to 7.23.2
dependabot[bot] Oct 19, 2023
c235353
Merge pull request #28 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 19, 2023
ceb9e81
chore(deps): bump next in /examples/form-builder/nextjs
dependabot[bot] Oct 25, 2023
d5c5377
chore(deps): bump next in /examples/redirects/nextjs
dependabot[bot] Oct 25, 2023
da1dfce
chore(deps): bump next from 13.4.12 to 13.5.0 in /templates/ecommerce
dependabot[bot] Oct 25, 2023
6f549c6
Merge pull request #29 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 25, 2023
862c84b
Merge pull request #30 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 25, 2023
e94f5f2
Merge pull request #32 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 25, 2023
60a5109
chore(deps): bump next from 13.4.8 to 13.5.0 in /examples/auth/next-app
dependabot[bot] Oct 25, 2023
74e7dde
chore(deps): bump next from 13.4.12 to 13.5.0 in /examples/custom-server
dependabot[bot] Oct 25, 2023
f3c858a
chore(deps): bump next in /examples/draft-preview/next-pages
dependabot[bot] Oct 25, 2023
d882739
chore(deps): bump next in /examples/auth/next-pages
dependabot[bot] Oct 25, 2023
eac3bff
chore(deps): bump next in /examples/draft-preview/next-app
dependabot[bot] Oct 25, 2023
e3583d7
Merge pull request #31 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 25, 2023
f42fc63
Merge pull request #33 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 25, 2023
1b10c1f
Merge pull request #34 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 25, 2023
49dbef6
Merge pull request #35 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 25, 2023
d528cc3
Merge pull request #36 from NastyApplication/dependabot/npm_and_yarn/…
NikolaRHristov Oct 25, 2023
ae81162
chore(deps): bump es5-ext from 0.10.62 to 0.10.64
dependabot[bot] Feb 27, 2024
f0e6feb
chore(deps): bump nodemailer in /examples/form-builder/cms
dependabot[bot] Mar 13, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,27 @@


# [1.14.0](https://github.com/payloadcms/payload/compare/v1.13.4...v1.14.0) (2023-08-16)


### Bug Fixes

* DatePicker showing only selected day by default ([#3169](https://github.com/payloadcms/payload/issues/3169)) ([edcb393](https://github.com/payloadcms/payload/commit/edcb3933cfb4532180c822135ea6a8be928e0fdc))
* only allow redirects to /admin sub-routes ([c0f05a1](https://github.com/payloadcms/payload/commit/c0f05a1c38fb9c958de920fabb698b5ecfb661f0))
* passes in height to resizeOptions upload option to allow height resize ([#3171](https://github.com/payloadcms/payload/issues/3171)) ([7963d04](https://github.com/payloadcms/payload/commit/7963d04a27888eb5a12d0ab37f2082cd33638abd))
* WhereBuilder component does not accept all valid Where queries ([#3087](https://github.com/payloadcms/payload/issues/3087)) ([fdfdfc8](https://github.com/payloadcms/payload/commit/fdfdfc83f36a958971f8e4e4f9f5e51560cb26e0))


### Features

* add afterOperation hook ([#2697](https://github.com/payloadcms/payload/issues/2697)) ([33686c6](https://github.com/payloadcms/payload/commit/33686c6db8373a16d7f6b0192e0701bf15881aa4))
* add support for hotkeys ([#1821](https://github.com/payloadcms/payload/issues/1821)) ([942cfec](https://github.com/payloadcms/payload/commit/942cfec286ff050e13417b037cca64b9d757d868))
* Added Azerbaijani language file ([#3164](https://github.com/payloadcms/payload/issues/3164)) ([63e3063](https://github.com/payloadcms/payload/commit/63e3063b9ecc1afd62d7a287a798d41215008f2a))
* allow async relationship filter options ([#2951](https://github.com/payloadcms/payload/issues/2951)) ([bad3638](https://github.com/payloadcms/payload/commit/bad363882c9d00d3c73547ca3329eba988e728ff))
* Improve admin dashboard accessibility ([#3053](https://github.com/payloadcms/payload/issues/3053)) ([e03a8e6](https://github.com/payloadcms/payload/commit/e03a8e6b030e82a17e1cdae5b4032433cf9c75a4))
* improve field ops ([#3172](https://github.com/payloadcms/payload/issues/3172)) ([d91b44c](https://github.com/payloadcms/payload/commit/d91b44cbb3fd526caca2a6f4bd30fd06ede3a5da))
* make PAYLOAD_CONFIG_PATH optional ([#2839](https://github.com/payloadcms/payload/issues/2839)) ([5744de7](https://github.com/payloadcms/payload/commit/5744de7ec63e3f17df7e02a7cc827818a79dbbb8))
* text alignment for richtext editor ([#2803](https://github.com/payloadcms/payload/issues/2803)) ([a0b13a5](https://github.com/payloadcms/payload/commit/a0b13a5b01fa0d7f4c4dffd1895bfe507e5c676d))

## [1.13.4](https://github.com/payloadcms/payload/compare/v1.13.3...v1.13.4) (2023-08-11)


Expand Down
6 changes: 6 additions & 0 deletions CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ Payload documentation can be found directly within its codebase and you can feel

If you're an incredibly awesome person and want to help us make Payload even better through new features or additions, we would be thrilled to work with you.

## Design Contributions

When it comes to design-related changes or additions, it's crucial for us to ensure a cohesive user experience and alignment with our broader design vision. Before embarking on any implementation that would affect the design or UI/UX, we ask that you **first share your design proposal** with us for review and approval.

Our design review ensures that proposed changes fit seamlessly with other components, both existing and planned. This step is meant to prevent unintentional design inconsistencies and to save you from investing time in implementing features that might need significant design alterations later.

### Before Starting

To help us work on new features, you can create a new feature request post in [GitHub Discussion](https://github.com/payloadcms/payload/discussions) or discuss it in our [Discord](https://discord.com/invite/payload). New functionality often has large implications across the entire Payload repo, so it is best to discuss the architecture and approach before starting work on a pull request.
Expand Down
26 changes: 4 additions & 22 deletions docs/fields/rich-text.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ keywords: rich text, fields, config, configuration, documentation, Content Manag
---

<Banner>
The Rich Text field is a powerful way to allow editors to write dynamic
content. The content is saved as JSON in the database and can be converted
into any format, including HTML, that you need.
The Rich Text field is a powerful way to allow editors to write dynamic content. The content is saved as JSON in the database and can be converted into any format, including HTML, that you need.
</Banner>

<LightDarkImage
Expand All @@ -22,14 +20,7 @@ keywords: rich text, fields, config, configuration, documentation, Content Manag
The Admin component is built on the powerful [`slatejs`](https://docs.slatejs.org/) editor and is meant to be as extensible and customizable as possible.

<Banner type="success">
<strong>
Consistent with Payload's goal of making you learn as little of Payload as
possible, customizing and using the Rich Text Editor does not involve
learning how to develop for a <em>Payload</em> rich text editor.
</strong>{" "}
Instead, you can invest your time and effort into learning Slate, an
open-source tool that will allow you to apply your learnings elsewhere as
well.
<strong>Consistent with Payload's goal of making you learn as little of Payload as possible, customizing and using the Rich Text Editor does not involve learning how to develop for a <em>Payload</em> rich text editor.</strong> Instead, you can invest your time and effort into learning Slate, an open-source tool that will allow you to apply your learnings elsewhere as well.
</Banner>

### Config
Expand Down Expand Up @@ -125,13 +116,7 @@ The built-in `relationship` element is a powerful way to reference other Documen
Similar to the `relationship` element, the `upload` element is a user-friendly way to reference [Upload-enabled collections](/docs/upload/overview) with a UI specifically designed for media / image-based uploads.

<Banner type="success">
<strong>Tip:</strong>
<br />
Collections are automatically allowed to be selected within the Rich Text
relationship and upload elements by default. If you want to disable a
collection from being able to be referenced in Rich Text fields, set the
collection admin options of <strong>enableRichTextLink</strong> and{" "}
<strong>enableRichTextRelationship</strong> to false.
<strong>Tip:</strong><br />Collections are automatically allowed to be selected within the Rich Text relationship and upload elements by default. If you want to disable a collection from being able to be referenced in Rich Text fields, set the collection admin options of <strong>enableRichTextLink</strong> and <strong>enableRichTextRelationship</strong> to false.
</Banner>

Relationship and Upload elements are populated dynamically into your Rich Text field' content. Within the REST and Local APIs, any present RichText `relationship` or `upload` elements will respect the `depth` option that you pass, and will be populated accordingly. In GraphQL, each `richText` field accepts an argument of `depth` for you to utilize.
Expand Down Expand Up @@ -307,10 +292,7 @@ const serialize = (children) =>
```

<Banner>
<strong>Note:</strong>
<br />
The above example is for how to render to JSX, although for plain HTML the
pattern is similar. Just remove the JSX and return HTML strings instead!
<strong>Note:</strong><br />The above example is for how to render to JSX, although for plain HTML the pattern is similar. Just remove the JSX and return HTML strings instead!
</Banner>

### Built-in SlateJS Plugins
Expand Down
63 changes: 42 additions & 21 deletions docs/hooks/collections.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Collections feature the ability to define the following hooks:
- [afterRead](#afterread)
- [beforeDelete](#beforedelete)
- [afterDelete](#afterdelete)
- [afterOperation](#afteroperation)

Additionally, `auth`-enabled collections feature the following hooks:

Expand All @@ -31,6 +32,7 @@ Additionally, `auth`-enabled collections feature the following hooks:
All collection Hook properties accept arrays of synchronous or asynchronous functions. Each Hook type receives specific arguments and has the ability to modify specific outputs.

`collections/exampleHooks.js`

```ts
import { CollectionConfig } from 'payload/types';

Expand All @@ -48,6 +50,7 @@ export const ExampleHooks: CollectionConfig = {
afterChange: [(args) => {...}],
afterRead: [(args) => {...}],
afterDelete: [(args) => {...}],
afterOperation: [(args) => {...}],

// Auth-enabled hooks
beforeLogin: [(args) => {...}],
Expand All @@ -62,19 +65,19 @@ export const ExampleHooks: CollectionConfig = {

### beforeOperation

The `beforeOperation` Hook type can be used to modify the arguments that operations accept or execute side-effects that run before an operation begins.
The `beforeOperation` hook can be used to modify the arguments that operations accept or execute side-effects that run before an operation begins.

Available Collection operations include `create`, `read`, `update`, `delete`, `login`, `refresh` and `forgotPassword`.
Available Collection operations include `create`, `read`, `update`, `delete`, `login`, `refresh`, and `forgotPassword`.

```ts
import { CollectionBeforeOperationHook } from 'payload/types';
import { CollectionBeforeOperationHook } from "payload/types";

const beforeOperationHook: CollectionBeforeOperationHook = async ({
args, // Original arguments passed into the operation
args, // original arguments passed into the operation
operation, // name of the operation
}) => {
return args; // Return operation arguments as necessary
}
return args; // return modified operation arguments as necessary
};
```

### beforeValidate
Expand All @@ -88,7 +91,7 @@ Please do note that this does not run before the client-side validation. If you
3. `validate` runs on the server

```ts
import { CollectionBeforeOperationHook } from 'payload/types';
import { CollectionBeforeOperationHook } from "payload/types";

const beforeValidateHook: CollectionBeforeValidateHook = async ({
data, // incoming data to update or create with
Expand All @@ -97,15 +100,15 @@ const beforeValidateHook: CollectionBeforeValidateHook = async ({
originalDoc, // original document
}) => {
return data; // Return data to either create or update a document with
}
};
```

### beforeChange

Immediately following validation, `beforeChange` hooks will run within `create` and `update` operations. At this stage, you can be confident that the data that will be saved to the document is valid in accordance to your field validations. You can optionally modify the shape of data to be saved.

```ts
import { CollectionBeforeChangeHook } from 'payload/types';
import { CollectionBeforeChangeHook } from "payload/types";

const beforeChangeHook: CollectionBeforeChangeHook = async ({
data, // incoming data to update or create with
Expand All @@ -114,15 +117,15 @@ const beforeChangeHook: CollectionBeforeChangeHook = async ({
originalDoc, // original document
}) => {
return data; // Return data to either create or update a document with
}
};
```

### afterChange

After a document is created or updated, the `afterChange` hook runs. This hook is helpful to recalculate statistics such as total sales within a global, syncing user profile changes to a CRM, and more.

```ts
import { CollectionAfterChangeHook } from 'payload/types';
import { CollectionAfterChangeHook } from "payload/types";

const afterChangeHook: CollectionAfterChangeHook = async ({
doc, // full document data
Expand All @@ -131,31 +134,31 @@ const afterChangeHook: CollectionAfterChangeHook = async ({
operation, // name of the operation ie. 'create', 'update'
}) => {
return doc;
}
};
```

### beforeRead

Runs before `find` and `findByID` operations are transformed for output by `afterRead`. This hook fires before hidden fields are removed and before localized fields are flattened into the requested locale. Using this Hook will provide you with all locales and all hidden fields via the `doc` argument.

```ts
import { CollectionBeforeReadHook } from 'payload/types';
import { CollectionBeforeReadHook } from "payload/types";

const beforeReadHook: CollectionBeforeReadHook = async ({
doc, // full document data
req, // full express request
query, // JSON formatted query
}) => {
return doc;
}
};
```

### afterRead

Runs as the last step before documents are returned. Flattens locales, hides protected fields, and removes fields that users do not have access to.

```ts
import { CollectionAfterReadHook } from 'payload/types';
import { CollectionAfterReadHook } from "payload/types";

const afterReadHook: CollectionAfterReadHook = async ({
doc, // full document data
Expand All @@ -164,7 +167,7 @@ const afterReadHook: CollectionAfterReadHook = async ({
findMany, // boolean to denote if this hook is running against finding one, or finding many
}) => {
return doc;
}
};
```

### beforeDelete
Expand Down Expand Up @@ -194,19 +197,37 @@ const afterDeleteHook: CollectionAfterDeleteHook = async ({
}) => {...}
```

### afterOperation

The `afterOperation` hook can be used to modify the result of operations or execute side-effects that run after an operation has completed.

Available Collection operations include `create`, `find`, `findByID`, `update`, `updateByID`, `delete`, `deleteByID`, `login`, `refresh`, and `forgotPassword`.

```ts
import { CollectionAfterOperationHook } from "payload/types";

const afterOperationHook: CollectionAfterOperationHook = async ({
args, // arguments passed into the operation
operation, // name of the operation
result, // the result of the operation, before modifications
}) => {
return result; // return modified result as necessary
};
```

### beforeLogin

For auth-enabled Collections, this hook runs during `login` operations where a user with the provided credentials exist, but before a token is generated and added to the response. You can optionally modify the user that is returned, or throw an error in order to deny the login operation.

```ts
import { CollectionBeforeLoginHook } from 'payload/types';
import { CollectionBeforeLoginHook } from "payload/types";

const beforeLoginHook: CollectionBeforeLoginHook = async ({
req, // full express request
user, // user being logged in
}) => {
return user;
}
};
```

### afterLogin
Expand Down Expand Up @@ -267,15 +288,15 @@ const afterMeHook: CollectionAfterMeHook = async ({
For auth-enabled Collections, this hook runs after successful `forgotPassword` operations. Returned values are discarded.

```ts
import { CollectionAfterForgotPasswordHook } from 'payload/types';
import { CollectionAfterForgotPasswordHook } from "payload/types";

const afterLoginHook: CollectionAfterForgotPasswordHook = async ({
req, // full express request
user, // user being logged in
token, // user token
}) => {
return user;
}
};
```

## TypeScript
Expand All @@ -298,5 +319,5 @@ import type {
CollectionAfterRefreshHook,
CollectionAfterMeHook,
CollectionAfterForgotPasswordHook,
} from 'payload/types';
} from "payload/types";
```
2 changes: 1 addition & 1 deletion examples/auth/next-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
},
"dependencies": {
"escape-html": "^1.0.3",
"next": "^13.4.8",
"next": "^13.5.0",
"react": "18.2.0",
"react-dom": "18.2.0",
"react-hook-form": "^7.45.1"
Expand Down
Loading