Back

phone verification does not work for more than one user

  • 0
  • Android
  • Flutter
  • Auth
  • Cloud
Ahmet Bey
30 Jul, 2024, 12:12

Hello, I am using phone authentication for my project. I am sending the code using createPhoneToken and verify the code with updatePhoneSession. It verifies correctly when there is only one user in the database but after the first user is verified, the second user still gets the SMS code but the verification code cannot be verified. Here is my code, could you please indicate what I am doing wrong. Thank you for your help.

Future<String> sendPhoneVerificationCode(String phone) async { try { final token = await _account.createPhoneToken( userId: ID.unique(), phone: phone, ); return token.userId; } catch (e) { rethrow; } }

Future<models.Session> verifyPhoneCode(String userId, String code) async { try { final session = await _account.updatePhoneSession( userId: userId, secret: code, ); return session; } catch (e) { rethrow; } }

TL;DR
Phone verification works for one user, but not for multiple users. The issue arises during verification after the first user. The code appears correct. This issue might be due to the reuse of the same phone number. Consider generating unique phone numbers for each user to resolve this problem.
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