Skip to content

Commit e90ad0f

Browse files
committed
fix: return shape
1 parent 05fd632 commit e90ad0f

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

packages/auth/src/payload-jwt/authenticateRequest.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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

Comments
 (0)