@@ -67,14 +67,23 @@ export const PayloadSessionProvider: React.FC<Props<CollectionSlug>> = <
6767 */
6868 const fetchSession = useCallback (
6969 async ( { signal } : { signal ?: AbortSignal } = { } ) => {
70- // Fetch the session from the server
70+ /**
71+ * Fetch the session from the server
72+ *
73+ * @see https://payloadcms.com/docs/rest-api/overview#auth-operations
74+ */
7175 const response = await fetch ( `/api/${ userCollectionSlug } /me` , {
7276 signal,
7377 } ) ;
7478 const result : {
7579 user : DataFromCollectionSlug < TSlug > | null ;
7680 exp : number ;
7781 collection ?: CollectionSlug ;
82+ /**
83+ * @deprecated Use user._strategy instead
84+ *
85+ * @see https://github.com/payloadcms/payload/pull/11701
86+ */
7887 strategy ?: string ;
7988 } = await response . json ( ) ;
8089
@@ -91,7 +100,7 @@ export const PayloadSessionProvider: React.FC<Props<CollectionSlug>> = <
91100 user : result . user ,
92101 expires : new Date ( result . exp * 1000 ) . toISOString ( ) ,
93102 collection : result . collection ,
94- strategy : result . strategy ,
103+ strategy : result . user . _strategy ?? result . strategy , // Extract the strategy from user._strategy or for legacy support directly from the result
95104 } ;
96105 setLocalSession ( localSession ) ;
97106
@@ -121,12 +130,23 @@ export const PayloadSessionProvider: React.FC<Props<CollectionSlug>> = <
121130 * Function to refresh the session
122131 */
123132 const refresh = async ( ) => {
124- // Refresh the session on the server
133+ /**
134+ * Refresh the session on the server
135+ *
136+ * @see https://payloadcms.com/docs/rest-api/overview#auth-operations
137+ */
125138 const response = await fetch ( `/api/${ userCollectionSlug } /refresh-token` , {
126139 method : "POST" ,
127140 } ) ;
128- const result : { user : DataFromCollectionSlug < TSlug > | null ; exp : number } =
129- await response . json ( ) ;
141+ const result : {
142+ user : DataFromCollectionSlug < TSlug > | null ;
143+ exp : number /**
144+ * @deprecated Use user._strategy instead
145+ *
146+ * @see https://github.com/payloadcms/payload/pull/11701
147+ */ ;
148+ strategy ?: string ;
149+ } = await response . json ( ) ;
130150
131151 // If the response is not ok or the user is not present, return null
132152 if ( ! response . ok || ! result . user ) {
@@ -137,6 +157,8 @@ export const PayloadSessionProvider: React.FC<Props<CollectionSlug>> = <
137157 const localSession = {
138158 user : result . user ,
139159 expires : new Date ( result . exp * 1000 ) . toISOString ( ) ,
160+ collection : result . user . collection ?? userCollectionSlug ,
161+ strategy : result . user . _strategy ?? result . strategy , // Extract the strategy from user._strategy or for legacy support directly from the result
140162 } ;
141163 setLocalSession ( localSession ) ;
142164
0 commit comments