Prevent sending password sms when country prefix is unsupported

Hi,
we’re using auth-lock 11.24.0
we are implementing passwordless login.

We would like to prevent from users with phone number that has prefix different from +1 to login to our app.

to be precise,
when a user submits phone number with prefix different from +1, we would like to show an error explaining the situation, and of course prevent sending them the sms with the password (i.e. prevent moving to the ‘enter password received’ page).

can this be done somehow?

I understand there are Rules and Actions, but not sure if that answers our needs exactly.
also saw this: Raise Errors from Rules

will appreciate any input explaining how exactly can that be achieved, or of course if it cannot.

thanks a lot!

@rueben.tiow is anyone available to help on this one please?

Hi @nitzan.mazor,

Thanks for reaching out to the Auth0 Community!

Before we continue, have you gotten a chance to see my last reply in another previous topic we shared:

After using the newly provided Rule snippet, you should log the user out so that they are allowed to retry to log in. If not, the user will be in an endless loop, as you found in the Raise Errors from Rules doc.

Please let me know how this works for you.

Thanks.

Thanks for your response @rueben.tiow.

I couldn’t really understand how raising error from rules work.
is there a more detailed explanation or example?
or maybe if you can explain a bit more?

Thanks

Hi @nitzan.mazor,

Thank you for your response.

Sure, I will explain further.

Rules are triggered immediately after logging in. So, in this case, we allow the user to use their phone number to attempt to log in. After they have provided the code to log in, the Rule will be triggered and checks for the phone number prefix.

If the user’s phone number begins with +1, they will be redirected to the callback URL page with an error message defined in the Rule itself.

Does that help?