lively-scientist-17848
10/22/2024, 10:55 AMbrief-egg-61061
10/22/2024, 10:55 AMbrief-egg-61061
10/22/2024, 10:56 AMverified_addresses
in your Social Sign-In Jsonnet snippet. Here's an example of how to do this: jsonnet local claims = { email_verified: false, } + std.extVar('claims'); { identity: { traits: { [if 'email' in claims && claims.email_verified then 'email' else null]: claims.email, given_name: claims.given_name, family_name: claims.family_name, }, verified_addresses: std.prune([ // Carry over verified status from Social Sign-In provider. if 'email' in claims && claims.email_verified then { via: 'email', value: claims.email }, ]), }, }
This code snippet checks if the email
claim is present and if the email_verified
claim is true. If both conditions are met, it adds the email to the verified_addresses
field of the identity. Please note that this only works if the verified address is also present in the identity's traits and marked as a verifiable email. Here's an example of how to mark an email as verifiable in the identity schema: jsonnet { "$id": "<https://example.com/person.schema.json>", "$schema": "<http://json-schema.org/draft-07/schema#>", title: "Person", type: "object", properties: { traits: { type: "object", properties: { email: { format: "email", type: "string", "<http://ory.sh/kratos|ory.sh/kratos>": { verification: { via: "email", }, }, }, }, required: ["subject"], }, }, }
In this schema, the email
trait is marked as verifiable via email. For more information, you can refer to the [Ory documentation](https://www.ory.sh/docs/kratos/self-service/flows/verify-email-account-activation#carry-over-verified-status-from-social-sign-in).