<@U04UQ68083H> is it possible to have two login co...
# ory-copilot
m
@chilly-king-10285 is it possible to have two login code channels like SMS and Email but show only SMS (if phone exists) in UI for login , using kratos config
b
A message from kapa.ai
Based on the knowledge sources, it is possible to configure Ory Kratos to support both SMS and email as login code channels while controlling which one is shown in the UI. However, this would require a custom UI implementation rather than just Kratos configuration. The knowledge sources show that Kratos supports both email and SMS for one-time codes, and you can define both in your identity schema:
Copy code
json {   "traits": {     "type": "object",     "properties": {       "email": {         "type": "string",         "format": "email",         "title": "Your email",         "<http://ory.sh/kratos|ory.sh/kratos>": {           "credentials": {             "code": {               "identifier": true,               "via": "email"             }           }         }       },       "phone_number": {         "type": "string",         "format": "tel",         "title": "Your phone number",         "<http://ory.sh/kratos|ory.sh/kratos>": {           "credentials": {             "code": {               "identifier": true,               "via": "sms"             }           }         }       }     }   } }
However, the default UI behavior isn't directly configurable to show only SMS when a phone exists. According to the discussion in [Unify sign-in and sign-in page to single input for passwordless "code" login](https://github.com/ory/kratos/discussions/4294), you would need to create a custom UI that: 1. Initially checks if the user has a phone number in their profile 2. If a phone number exists, only shows the SMS option 3. Otherwise, falls back to email The official answer in that discussion mentions: > "This should be possible using a custom UI... you have to create a custom UI that initially only shows an email input field. After email submission, checks if the email exists (you might need to implement this check in your backend)." You would need to implement this logic in your custom UI layer rather than through Kratos configuration alone. Kratos provides the authentication mechanisms, but the presentation layer would need to be customized to achieve this specific behavior.