From 9212c2aa11a09924be19d6d613bdee0311ee9e9f Mon Sep 17 00:00:00 2001 From: Henning Perl Date: Tue, 21 Apr 2026 19:50:04 +0200 Subject: [PATCH 1/2] fix: document proper claim update logic --- docs/kratos/social-signin/90_data-mapping.mdx | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/docs/kratos/social-signin/90_data-mapping.mdx b/docs/kratos/social-signin/90_data-mapping.mdx index 9172c5a81..8767f4ba9 100644 --- a/docs/kratos/social-signin/90_data-mapping.mdx +++ b/docs/kratos/social-signin/90_data-mapping.mdx @@ -266,13 +266,14 @@ Example: update the user's groups from the provider while preserving an existing local claims = std.extVar('claims'); local identity = std.extVar('identity'); +// Keep the display name if the user has set one, otherwise use the one from the provider (if any). +local displayName = std.get(identity.traits, "display_name", std.get(claims, "display_name", "")); + { identity: { traits: { email: claims.email, - // Keep the display name if the user has set one. - [if "display_name" in identity.traits && identity.traits.display_name != "" then "display_name"]: - identity.traits.display_name, + [if displayName != "" then "display_name"]: displayName, // Always update groups from the provider. [if "groups" in claims.raw_claims then "groups" else null]: claims.raw_claims.groups, From 428ad254d1eed249513655b595b211b0247b8789 Mon Sep 17 00:00:00 2001 From: Henning Perl Date: Wed, 22 Apr 2026 10:34:11 +0200 Subject: [PATCH 2/2] code review --- docs/kratos/social-signin/90_data-mapping.mdx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/kratos/social-signin/90_data-mapping.mdx b/docs/kratos/social-signin/90_data-mapping.mdx index 8767f4ba9..feae537e8 100644 --- a/docs/kratos/social-signin/90_data-mapping.mdx +++ b/docs/kratos/social-signin/90_data-mapping.mdx @@ -273,7 +273,7 @@ local displayName = std.get(identity.traits, "display_name", std.get(claims, "di identity: { traits: { email: claims.email, - [if displayName != "" then "display_name"]: displayName, + [if displayName != "" then "display_name" else null]: displayName, // Always update groups from the provider. [if "groups" in claims.raw_claims then "groups" else null]: claims.raw_claims.groups,