Skip to content
Init is here / May 19 - 23
Back

Checking if a phone number already exists while signing for otp.

  • 0
  • Users
  • Accounts
shera_x
20 Jan, 2024, 06:13

Hi, my app uses only phone number based OTP authentication. As far as I know, appwrite creates a new user if a user is not present with that phone number. And I want the client to get an error if the phone number they gave is already registered. Is there a way to achieve this in appwrite?

TL;DR
To check if a phone number already exists during OTP authentication in Appwrite, you cannot directly do this using the client SDK. However, you can use server API functions to achieve this. Here's how you can do it: 1. Use a server API function to check if a user with the provided phone number already exists. 2. Call this function using the client SDK. 3. If the function returns a user, it means the phone number is already registered and you can handle the error on the client side. By following these steps, you can ensure that the client receives an error if the phone number they provided is already registered.
kamal.panara
20 Jan, 2024, 06:51

If phone number is new then Appwrite will create new user else it will just create new session, so you can’t directly check this from client SDK.

you can use functions with server API to check if user with phone already exists or not. And you can call function using client SDK.

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more