Flutter Firebase auth的请求太多
我正在我的flutter应用程序上构建电子邮件验证页面,以供用户在登录之前验证他们的电子邮件。 。
Future sendVerificationEmail() async {
try{
final user = FirebaseAuth.instance.currentUser!;
await user.sendEmailVerification();
setState(() => canResendEmail = false);
await Future.delayed(const Duration(seconds: 5));
canResendEmail = true;
}catch (e) {
Utils.showSnackBar(e.toString());
}
}
...............................
ElevatedButton.icon(
icon: const Icon(Icons.email, size: 32),
label: const Text("Resend email"
),
onPressed: canResendEmail ? sendVerificationEmail : null,
),
但是,问题是当我尝试再次重新发送电子邮件时,大多数时候我会收到错误的错误:
[firebase-auth/太多请求]由于异常活动,我们已经阻止了该设备的所有请求。稍后再试。
好吧,我知道这非常适合安全,但根本不一致。像有时,我可以在30秒内重新发送5封电子邮件,有时会在2分钟以上显示此错误。 我的问题是,我是否可以在firebase中设置一些规则,以使我想每秒发送一定数量的电子邮件请求,或者至少想知道我需要等待的确切时间是什么而不是在这种情况下,有时我可以在短时间内发送多个请求。
I was building an email verification page on my flutter app for users to verify their emails before they can sign in. So in the verification page, I have a button that allows the users to resend the verfication email after 5 seconds from the time they sent.
Future sendVerificationEmail() async {
try{
final user = FirebaseAuth.instance.currentUser!;
await user.sendEmailVerification();
setState(() => canResendEmail = false);
await Future.delayed(const Duration(seconds: 5));
canResendEmail = true;
}catch (e) {
Utils.showSnackBar(e.toString());
}
}
...............................
ElevatedButton.icon(
icon: const Icon(Icons.email, size: 32),
label: const Text("Resend email"
),
onPressed: canResendEmail ? sendVerificationEmail : null,
),
But then the problem is when I try to resend the email again, most of the time i get the error which says:
[firebase-auth/too many requests] We have blocked all requests from this device due to unusual activity. Try again later.
Well, I understand that this is great for security but its just not consistent at all. Like sometimes I can resend 5 emails within 30 seconds and sometimes it will keep showing this error for more than 2 minuetes.
My question is whether i can set some rules in the firebase to make that I can like send certain number of email requests per seconds or like at least get to know what is the exact time that I need to wait before I can send a request again instead of this random situation where sometimes I can send multiple requests within short time.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我能够通过设置提供的选项来克服这一点,以在测试活动期间禁用验证检查(请参阅文档在这里)。看起来像这样:
I was able to get past this by setting a provided option to disable the verification check during testing activities (see documentation here). It looks like this: