<@U04UQ68083H> With Kratos, how to implement mergi...
# ory-copilot
b
@chilly-king-10285 With Kratos, how to implement merging of credentials?
c
A message from kapa.ai
In Ory Kratos, you can manage multiple credentials for a single identity. For example, a user might have a password credential and an OpenID Connect (OIDC) credential. These credentials can be associated with the same or different identifiers, such as email addresses. Here is an example of two separate identities with different credentials but the same identifier:
Copy code
markdown # Identity 1   credentials:     password:       id: password       identifiers:         - [[email protected]](<https://www.ory.sh/cdn-cgi/l/email-protection>)   ---   # Identity 2   credentials:     oidc:       id: oidc       identifiers:         - [[email protected]](<https://www.ory.sh/cdn-cgi/l/email-protection>)
(Source: [Ory Kratos Concepts](https://www.ory.sh/docs/kratos/concepts/credentials)) When using a custom identity schema, you can mark the fields which are the password identifiers (username, email, phone number). For example, to allow both the username and email address for signing in, you can define the following for both
username
and
email
fields:
Copy code
json {     // ...     "<http://ory.sh/kratos|ory.sh/kratos>": {       credentials: {         password: {           identifier: true,         },       },     },   }
(Source: [Ory Kratos Concepts - Custom Identity Schema](https://www.ory.sh/docs/kratos/concepts/credentials/username-email-password#custom-identity-schema)) Please note that merging of credentials should be done carefully to maintain the security and integrity of user data.