How to configure mobile number + otp based auth alongside email + password #4508
-
|
I have installed ory kratos and hydra stack. I am able to get jwt tokens and also implement role based access controls. But now i want a dual login flow where users have a choice to sign up using email id and password or use mobile number + otp to sign up. The method used for sign up would be same used for sign in. But i am not able to integrate the mobile number + otp part here I am attaching my configuration files below Note: I am not talking about the mfa using sms after email + password. |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
Hello @anshbhimani2 Two main things are missing / misplaced in your config: Identity schema is not configured for phone+code login In identity.schema.json, the phone trait must be marked as a code identifier via SMS, otherwise the code method can’t use it. For example:[Identity extensions; Passwordless custom schema] (Keep your existing email trait with password.identifier: true.) SMS delivery must be configured under courier, not under selfservice.methods.code Kratos sends SMS via the courier SMS channel, not via fields like delivery_method or sms: on the code method. You need something like:[Send SMS] And optionally SMS templates for login_code / recovery_code / verification_code if you want to control the SMS body.[Send SMS templates] Optional but often desired: Add a session hook after code registration so users who sign up by phone+OTP are logged in immediately:[Successful registration; Sign in after registration] Let me know if that helps. |
Beta Was this translation helpful? Give feedback.
-
|
@vinckr Thanks for the help |
Beta Was this translation helpful? Give feedback.
Hello @anshbhimani2
Two main things are missing / misplaced in your config:
Identity schema is not configured for phone+code login
In identity.schema.json, the phone trait must be marked as a code identifier via SMS, otherwise the code method can’t use it. For example:[Identity extensions; Passwordless custom schema]