<@U04UQ68083H> How can get ory to consider an emai...
# ory-copilot
l
@chilly-king-10285 How can get ory to consider an email address to have been verified that is obtained from a social sign in identity token?
b
A message from kapa.ai
To have Ory consider an email address as verified from a social sign-in identity token, you need to return
verified_addresses
in your Social Sign-In Jsonnet snippet. Here's an example of how to do this:
Copy code
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:
Copy code
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).