【发布时间】:2020-10-21 01:48:22
【问题描述】:
我必须在不使用 Firebase 身份验证的情况下创建手动注册并通过 Firestore 登录。 这种要求的原因是当用户想要重置他的密码时,首先我必须在他的电子邮件地址上向他发送一个确认码(MD5),当他收到代码时,他应该输入新密码,他必须粘贴该代码。 我将通过电子邮件向他发送一个代码,同时,该代码也将在 Firestore 中,稍后我将对其进行比较(代码是否正确)。 最后,(如果输入的密码正确,他的新密码将覆盖他之前存储在文档中的密码)。文档以电子邮件地址命名,这意味着电子邮件应该是唯一的。
这是我用于注册的代码:
void onPressedRegister(BuildContext context, String fullName, String email,
String password, String phoneNumber, dynamic formKey) {
if (formKey.currentState.validate()) {
db.collection("firestoreUsers").document(email).setData({
'fullName': fullName,
'email': email,
'password': password,
'phoneNumber': phoneNumber
});
现在我在登录时遇到问题,因为我无法检查用户是否存储在数据库中。这是我写的:
Future<bool> signInOverFirestore(String email, String password) async {
db
.collection('firestoreUsers')
.where('email', isEqualTo: email)
.getDocuments();
return true;
}
那么是否可以像这样登录并在以后从他的电子邮件中输入正确的代码时更新该用户?
【问题讨论】:
标签: firebase flutter google-cloud-firestore