feat: Integrate phone number verification handling for test numbers in authentication flow

This commit is contained in:
Achintha Isuru
2026-02-01 14:06:02 -05:00
parent 00999503e1
commit 23a346200a
2 changed files with 24 additions and 1 deletions

View File

@@ -4,6 +4,7 @@ import 'package:firebase_auth/firebase_auth.dart';
import 'package:firebase_data_connect/firebase_data_connect.dart';
import 'package:krow_data_connect/krow_data_connect.dart';
import 'package:krow_domain/krow_domain.dart' as domain;
import '../../utils/test_phone_numbers.dart';
import '../../domain/ui_entities/auth_mode.dart';
import '../../domain/repositories/auth_repository_interface.dart';
@@ -41,7 +42,17 @@ class AuthRepositoryImpl implements AuthRepositoryInterface {
await firebaseAuth.verifyPhoneNumber(
phoneNumber: phoneNumber,
verificationCompleted: (_) {
verificationCompleted: (PhoneAuthCredential credential) {
// Skip auto-verification for test numbers to allow manual code entry
if (TestPhoneNumbers.isTestNumber(phoneNumber)) {
return;
}
// For real numbers, we can support auto-verification if desired.
// But since this method returns a verificationId for manual OTP entry,
// we might not handle direct sign-in here unless the architecture changes.
// Currently, we just ignore it for the completer flow,
// or we could sign in directly if the credential is provided.
},
verificationFailed: (FirebaseAuthException e) {
if (!completer.isCompleted) {

View File

@@ -0,0 +1,12 @@
class TestPhoneNumbers {
static const List<String> values = [
'+15555555555', // Test User 1
'+15551234567', // Test User 2
'+16505551234', // Android Emulator
'+12345678910', // iOS Simulator
];
static bool isTestNumber(String phoneNumber) {
return values.contains(phoneNumber);
}
}