How use mobile number for authentication
-
Hi,
I want to use mobile number + password as my authentication fields and also
verify users using SMS verification code in the register process.
But I don't know how should I do that -
Hiya,
If you want to do this, you'll probably want to have the mobile number be the username (also known as the loginId). You can change the messages file in the theme so that anywhere the username field is shown, the corresponding label is "mobile phone number".
As far as using SMS verification, that will be something you have to build using the FusionAuth APIs. You would create a user using one of the user apis. Make sure you enable registration verification and then also pass the
skipRegistrationVerification
parameter to the API call.Then, you would send the SMS message using whatever method you want. Include a URL for your application and when the user enters the code correctly, you can call this method: https://fusionauth.io/docs/v1/tech/apis/registrations#resend-a-user-registration-verification-email with
sendVerifyRegistrationEmail
to false to get averificationId
and then this method to actually verify the number with thatverificationId
: https://fusionauth.io/docs/v1/tech/apis/registrations#verify-a-user-registrationSo basically you aren't sending any emails at all, you're just using the method calls to update the state of the user to verified.
Does that help?
-
Yeah, thanks.
And just another question: do you have any plan to support phone number just like email (to register using phone field, verify using SMS,..)? -
Hi @mehr-prs. We have an open issue that is tracking this:
https://github.com/FusionAuth/fusionauth-issues/issues/1
This feature is to support multiple identities, but it also covers adding new identity types. As part of this feature, we likely will implement support for phone number identities including full validation and verification for them.
Please upvote that issue if you feel it covers your requirements. This helps us prioritize features on our roadmap for the rest of 2020.
-
Please feel free to vote for the issue @mehr-prs , if it is important to you. Here's the general FusionAuth roadmap guidance: https://fusionauth.io/community/forum/topic/172/the-fusionauth-roadmap