![](/img/trans.png)
[英]how to reset the password if user forgot the password in firebase and flutter
[英]Do not warn if there is no registered user with Email address in Flutter Firebase Auth Password Reset
我正在使用 Flutter 开发应用程序。 我在 Firebase Auth 中重置密码时遇到问题。 如果没有属于输入的电子邮件地址的帐户,则会出错。 我想通过私人消息向用户显示此错误。
我写了这样的代码:
try {
_auth.sendPasswordResetEmail(email: _emailController.text);
ShowAlert(
context,
"Error",
"Password reset instructions have been sent to your email address."
);
} on FirebaseAuthException catch (e) {
if (e.code == "user-not-found") {
ShowAlert(
context,
"Error",
"No registered user with e-mail address was found."
);
} else {
ShowAlert(
context,
"Error",
"Unknown error occurred."
);
}
}
我编写了代码来向用户显示自定义消息,但不幸的是它不起作用。 它出现错误。
错误:
FirebaseAuthException ([firebase_auth/user-not-found] There is no user record corresponding to this identifier. The user may have been deleted.)
为什么会这样? 我怎么解决这个问题? 非常感谢您的帮助。
您不等待_auth.sendPasswordResetEmail()
的结果。 在它之前添加await
:
try {
await _auth.sendPasswordResetEmail(email: _emailController.text);
...
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.