Skip to content

Commit

Permalink
fix(clerk): Remove privateMetadata property from getCurrentUser (#7668)
Browse files Browse the repository at this point in the history
The privateMetadata property should not be accessible on the client side. This commit removes this property from the getCurrentUser function returned user object.

Co-authored-by: Stefanos Anagnostou <stefanos@clerk.dev>
  • Loading branch information
anagstef and anagstef authored Feb 22, 2023
1 parent d3d4f2b commit 3303ee7
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,14 @@ export const getCurrentUser = async (

const { roles } = parseJWT({ decoded })

// Remove privateMetadata property from CurrentUser as it should not be accessible on the web
const { privateMetadata, ...userWithoutPrivateMetadata } = decoded

if (roles) {
return { ...decoded, roles }
return { ...userWithoutPrivateMetadata, roles }
}

return { ...decoded }
return { ...userWithoutPrivateMetadata }
}

/**
Expand Down

0 comments on commit 3303ee7

Please sign in to comment.