@@ -127,7 +127,7 @@ export async function authenticateRequest({ req, payload }: AuthenticateRequestO
127127 }
128128}
129129
130- export async function authenticateRequestHeaders ( { headers, payload } : { headers : Headers , payload : Payload } ) : Promise < { user : User } > {
130+ export async function authenticateRequestHeaders ( { headers, payload } : { headers : Headers , payload : Payload } ) {
131131 if ( ! headers . get ( 'authorization' ) ) {
132132 throw createAuthError ( "No authorization header provided" , 401 ) ;
133133 }
@@ -161,7 +161,7 @@ export async function authenticateRequestHeaders({ headers, payload }: { headers
161161 overrideAccess : true ,
162162 } )
163163 console . log ( "Created new Payload user for Keycloak user:" , newUser . id , newUser . email )
164- return { user : newUser as User }
164+ return { user : { ... newUser , collection : 'users' as const } }
165165
166166 } else if ( payloadUser ) {
167167 // update user role if changed
@@ -178,7 +178,7 @@ export async function authenticateRequestHeaders({ headers, payload }: { headers
178178 console . log ( `Updated Payload user role for ${ payloadUser . email } to ${ permissions } ` ) ;
179179 }
180180
181- return { user : payloadUser as User }
181+ return { user : { ... payloadUser , collection : 'users' as const } }
182182
183183 } else {
184184 throw createAuthError ( "No user found for the given session" , 401 ) ;
0 commit comments