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";
77import { AUTHJS_STRATEGY_NAME } from "../../AuthjsAuthStrategy" ;
88import type { AuthjsPluginConfig } from "../../plugin" ;
99import { getRequestCollection } from "../../utils/getRequestCollection" ;
10+ import { revalidateTag } from "next/cache" ;
1011
1112/**
1213 * Override the default logout endpoint to destroy the authjs session
@@ -67,6 +68,9 @@ export const logoutEndpoint: (pluginOptions: AuthjsPluginConfig) => Endpoint = p
6768 // If the user is authenticated using authjs, we need to destroy the authjs session cookie
6869 if ( req . user ?. _strategy === AUTHJS_STRATEGY_NAME ) {
6970 await destroyAuthjsSessionCookie ( req , response , pluginOptions ) ;
71+
72+ // Revalidate the cache for the payload session
73+ revalidateTag ( "payload-session" ) ;
7074 }
7175
7276 return response ;
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ import NextAuth from "next-auth";
22import type { Endpoint , PayloadRequest } from "payload" ;
33import { generatePayloadCookie , headersWithCors , refreshOperation } from "payload" ;
44
5+ import { revalidateTag } from "next/cache" ;
56import { withPayload } from "../../../authjs/withPayload" ;
67import { AUTHJS_STRATEGY_NAME } from "../../AuthjsAuthStrategy" ;
78import type { AuthjsPluginConfig } from "../../plugin" ;
@@ -64,6 +65,9 @@ export const refreshEndpoint: (pluginOptions: AuthjsPluginConfig) => Endpoint =
6465 // If the user is authenticated using authjs, we need to refresh the authjs session cookie
6566 if ( result . user ?. _strategy === AUTHJS_STRATEGY_NAME ) {
6667 await refreshAuthjsSessionCookie ( req , response , pluginOptions ) ;
68+
69+ // Revalidate the cache for the payload session
70+ revalidateTag ( "payload-session" ) ;
6771 }
6872
6973 return response ;
You can’t perform that action at this time.
0 commit comments