Pre-User Registration Hook for Phone Number short/verification code

I’m building a Android and I would like to use Phone Number as Username instead of email with a password.
During user registration process, a SMS verification code should send to the user’s Phone and then user can activate their User Account by entering the same verification code on my Android App.

Apply Phone Number format Validation as part of Username similar to Passwordless

  • Any Rules example to apply this Validation during User Registration?
  • Any javascript example can be applied on Hosted Page?

Generate verification code and sending SMS

  • Does Hooks features is correct way to generate random 4 digit number and store against customer User.metadata.verificationcode (String), User.metadata.phonenumberverified (Boolean)
  • In term of sending SMS, i will create a WebTask which accept Phone Number/Verification Code and execute this WebTask request upon Pre-User Registration Hook.

User Account Activation via Verification Code

  • By assuming i store verification code on User.metadata.verificationcode, i will then create WebTask that accept ID Token and Verification Code. If found a match, i will set User.metadata.phonenumberverified (Boolean) as True, else reject.