我已经使用firebase和flutter创建了一个登录屏幕,一切正常,但是我希望用户使用真实的电子邮件(已验证)而不是任何电子邮件进行登录。
如果用户单击带有以下电子邮件的登录按钮:[email protected],它将接受此电子邮件。
如何验证电子邮件不是伪造的,并且实际上属于真实地址。
为了真正验证用户的电子邮件地址,您需要发送验证邮件,该邮件需要用户采取措施。
仅检查该地址是否存在是不够的,因为该电子邮件地址可能属于任何人。
您可以在Firebase控制台中设置邮件模板,并使用以下代码发送验证邮件。
FirebaseUser user = await _firebaseAuth.createUserWithEmailAndPassword(email: email, password: password);
try {
await user.sendEmailVerification();
return user.uid;
} catch (e) {
print("An error occured while trying to send email verification");
print(e.message);
}
}
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句