【发布时间】:2023-03-31 21:38:01
【问题描述】:
我想将电话号码与之前创建的帐户关联; 但是当我验证电话号码时,我发现了两种情况:
他们向用户发送带有代码的短信,当用户输入它时,我只是将手机保存在数据库中并结束。这个没有问题。
google 自动验证手机,不发送 MSG,我想是因为输入的号码 == sim 号码。这里的问题是它自动登录并在Auth中创建新的firebase用户,用户自动注销当前帐户并登录新帐户(电话号码) 我想阻止它自动创建帐户。有什么办法吗?
代码:
Future<void> verifyPhone() async {
final PhoneCodeAutoRetrievalTimeout autoRetrieve = (String verId) {
//this.verificationId = verId;
};
final PhoneCodeSent smsCodeSent = (String verId, [int forceCodeResend]) {
this.verificationId = verId;
smsCodeDialog(context).then((value) {
print('Signed in');
});
};
final PhoneVerificationCompleted verifiedSuccess = (FirebaseUser user) {
print('verified');
};
final PhoneVerificationFailed veriFailed = (AuthException exception) {
print('${exception.message}');
};
print("\n\n ${this.phoneNo} \n\n");
await FirebaseAuth.instance.verifyPhoneNumber(
phoneNumber: "+2${this.phoneNo.toString()}",
codeAutoRetrievalTimeout: autoRetrieve,
codeSent: smsCodeSent,
timeout: const Duration(seconds: 5),
verificationCompleted: verifiedSuccess,
verificationFailed: veriFailed,
);
}
【问题讨论】:
标签: firebase firebase-authentication flutter