File tree Expand file tree Collapse file tree 2 files changed +8
-0
lines changed
packages/payload-authjs/src/payload/collection/endpoints Expand file tree Collapse file tree 2 files changed +8
-0
lines changed Original file line number Diff line number Diff line change @@ -7,6 +7,7 @@ import { withPayload } from "../../../authjs/withPayload";
7
7
import { AUTHJS_STRATEGY_NAME } from "../../AuthjsAuthStrategy" ;
8
8
import type { AuthjsPluginConfig } from "../../plugin" ;
9
9
import { getRequestCollection } from "../../utils/getRequestCollection" ;
10
+ import { revalidateTag } from "next/cache" ;
10
11
11
12
/**
12
13
* Override the default logout endpoint to destroy the authjs session
@@ -67,6 +68,9 @@ export const logoutEndpoint: (pluginOptions: AuthjsPluginConfig) => Endpoint = p
67
68
// If the user is authenticated using authjs, we need to destroy the authjs session cookie
68
69
if ( req . user ?. _strategy === AUTHJS_STRATEGY_NAME ) {
69
70
await destroyAuthjsSessionCookie ( req , response , pluginOptions ) ;
71
+
72
+ // Revalidate the cache for the payload session
73
+ revalidateTag ( "payload-session" ) ;
70
74
}
71
75
72
76
return response ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import NextAuth from "next-auth";
2
2
import type { Endpoint , PayloadRequest } from "payload" ;
3
3
import { generatePayloadCookie , headersWithCors , refreshOperation } from "payload" ;
4
4
5
+ import { revalidateTag } from "next/cache" ;
5
6
import { withPayload } from "../../../authjs/withPayload" ;
6
7
import { AUTHJS_STRATEGY_NAME } from "../../AuthjsAuthStrategy" ;
7
8
import type { AuthjsPluginConfig } from "../../plugin" ;
@@ -64,6 +65,9 @@ export const refreshEndpoint: (pluginOptions: AuthjsPluginConfig) => Endpoint =
64
65
// If the user is authenticated using authjs, we need to refresh the authjs session cookie
65
66
if ( result . user ?. _strategy === AUTHJS_STRATEGY_NAME ) {
66
67
await refreshAuthjsSessionCookie ( req , response , pluginOptions ) ;
68
+
69
+ // Revalidate the cache for the payload session
70
+ revalidateTag ( "payload-session" ) ;
67
71
}
68
72
69
73
return response ;
You can’t perform that action at this time.
0 commit comments