Flutter 如何在用户登录之前监听电子邮件验证-firebase
我的应用程序允许用户注册并发送电子邮件进行验证。然而,我有一个问题,用户可以登录新的帐户,无论电子邮件是否验证。我已经找过了,但找不到解决这个问题的办法,因为我是个新手 我的身份验证码Flutter 如何在用户登录之前监听电子邮件验证-firebase,flutter,firebase-authentication,email-verification,Flutter,Firebase Authentication,Email Verification,我的应用程序允许用户注册并发送电子邮件进行验证。然而,我有一个问题,用户可以登录新的帐户,无论电子邮件是否验证。我已经找过了,但找不到解决这个问题的办法,因为我是个新手 我的身份验证码 Future<String> signIn(String email, String password) async { AuthResult result = await _firebaseAuth.signInWithEmailAndPassword( email: e
Future<String> signIn(String email, String password) async {
AuthResult result = await _firebaseAuth.signInWithEmailAndPassword(
email: email, password: password);
FirebaseUser user = result.user;
if (user.isEmailVerified) {
return user.uid;
} else {
return null;
}
}
Future<String> signUp(String email, String password) async {
AuthResult result = await _firebaseAuth.createUserWithEmailAndPassword(
email: email, password: password);
FirebaseUser user = result.user;
try {
await user.sendEmailVerification();
return user.uid;
} catch (e) {
print("An error occurred while trying to send email verification");
print(e.message);
}
}
你是如何使用signIn方法的?你能展示这部分代码吗?我已经编辑了代码你可以看到我的登录方法你是如何使用登录方法的?你能显示那部分代码吗?我已经编辑了代码,你可以看到我的登录方法
try {
if (_isLoginForm) {
userId = await widget.auth.signIn(_email, _password);
print('Signed in: $userId');
} else {
userId = await widget.auth.signUp(_email, _password);
//widget.auth.sendEmailVerification();
_showVerifyEmailSentDialog();
print('Signed up user: $userId');
}
setState(() {
_isLoading = false;
});
if (userId.length > 0 && userId != null && _isLoginForm) {
widget.loginCallback();
}