You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(next)!: allows auth strategies to return headers that need to be… (#6964)
## Description
Some authentication strategies may need to set headers for responses,
such as updating cookies via a refresh token, and similar. This PR
extends Payload's auth strategy capabilities with a manner of
accomplishing this.
This is a breaking change if you have custom authentication strategies
in Payload's 3.0 beta. But it's a simple one to update.
Instead of your custom auth strategy returning the `user`, now you must
return an object with a `user` property.
This is because you can now also optionally return `responseHeaders`,
which will be returned by Payload API responses if you define them in
your auth strategies. This can be helpful for cases where you need to
set cookies and similar, directly within your auth strategies.
Before:
```ts
return user
```
After:
```ts
return { user }
```
Copy file name to clipboardExpand all lines: docs/authentication/custom-strategies.mdx
+16-3Lines changed: 16 additions & 3 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -33,10 +33,12 @@ The `authenticate` function is passed the following arguments:
33
33
34
34
### Example Strategy
35
35
36
-
At its core a strategy simply takes information from the incoming request and returns a user. This is exactly how Payloads built-in strategies function.
36
+
At its core a strategy simply takes information from the incoming request and returns a user. This is exactly how Payload's built-in strategies function.
37
+
38
+
Your `authenticate` method should return an object containing a Payload user document and any optional headers that you'd like Payload to set for you when we return a response.
0 commit comments