miniature-hamburger-43394
04/11/2025, 10:50 PMbrief-egg-61061
04/11/2025, 10:50 PMbrief-egg-61061
04/11/2025, 10:50 PMjson { "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.