当用户电子邮件不再可访问时,重新发行Firebase Auth验证电子邮件
到目前为止,在我的项目中,我已经建立了一个基本的用户管理系统。但是,我无法找出一种在用户注册后重新发出验证链接 的方法。
例如:当用户注册时,createUserWitheMailandPassword
被称为返回承诺。现在,使用然后
(或等待)解决了承诺,sendemailerverification
被调用。这一切都很好。
注意: 上述流是我目前使用firebase auth
在客户端为用户管理实施的。
但是,如果用户碰巧删除此电子邮件,或者出于任何原因根本无法访问该电子邮件,该怎么办。我希望能够重新发出链接。
this> this > Firebase Admin SDK 在后端,是如何在服务器端生成验证电子邮件的示例。但是,看来它与帐户创建结合使用。此外,似乎firebase auth
遵循相同的限制。
不太确定接下来要去哪里,想知道是否有任何合适的解决方法。
谢谢。
So far in my project, I have set up a basic user management system. However, I'm unable to figure out a way to resend verification link after the user registers.
For example: When the user signs up, createUserWithEmailAndPassword
is called which returns a promise. The promise is now resolved using then
(or await
) to which sendEmailVerification
is called. This is all fine.
Note: The above flow is what I currently have implemented to for user management on the client side with Firebase Auth
.
However, what if the user happens to delete this email or for whatever reason has no access to it at all. I want to be able to resend the link.
This uses Firebase Admin SDK
on the backend and is an example of how to generate the verification email on the server-side. However, it appears that it is used in conjunction with account creation. In addition, it appears that Firebase Auth
follows the same set of restrictions.
Not too sure where to go next and was wondering if there are any suitable workarounds.
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
将链接添加到登录页面以重新发送验证电子邮件。
然后,沿着这些行触发某些内容:
另一个选择是在登录过程中检查用户是否验证了电子邮件。如果没有,请重新发送。沿着这些线:
Add a link to the login page to resend the verification email.
Then, trigger something along these lines:
Another option is to check during the login process whether the user verified the email. If not, resend it. Along these lines:
我认为这里描述的问题如下(我也面临):
=>一些新用户输入他的电子邮件和密码以创建一个帐户
=>我们调用CreateUserWitheMailandPassword(电子邮件,密码)=>可以在“身份验证” =&gt下在firebase控制台中找到帐户;在App auth.currentuser中不是null。这是因为ACC。为了记录我们阅读的“ CreateUserWitheMailandPassword”的含水:
“ @remarks
成功创建用户帐户时,此用户也将在您的应用程序中签署。”
=>然后,我们致电SendeMailVerification(Auth.CurrentUser) - 一切都有效,用户auth.currentuser获取了带有验证链接的电子邮件。
但。如果他不单击此链接(也许是垃圾邮件)怎么办?他将其塞了,时间过去了,他可能关闭PC或关闭应用程序。一段时间后再次尝试:打开应用程序,尝试再次注册...
=>当他再次输入与第一次尝试注册时输入的电子邮件相同的电子邮件时,我们的CreateUserWitheMailandPassword()将会给出错误(因为即使没有验证了该电子邮件的用户,也已经在数据库)=> auth.currentuser将为null(!!!)
=>如果您现在尝试使用SendeMailVerification(Auth.CurrentUser)“重新发送验证电子邮件” - 它不会发送任何内容。因为用户为空。
因此,摆脱这种情况的出路是仅基于电子邮件生成检验链接,并通过电子邮件以某种方式将其发送给用户:
https://firebase.google.com/docs/docs/auth/auth/admin/admin/email-action-link-links#java_2
The problem described here I think is as follows ( I am facing it as well):
=> some new User enters his Email and Password to create an account
=> we call createUserWithEmailAndPassword(email, password) => account can be found in firebase console under "Authentication" => in the app Auth.currentUser is NOT NULL. This is because acc. to documentatoin of "createUserWithEmailAndPassword" we read:
"@remarks
On successful creation of the user account, this user will also be signed in to your application."
=> Then we call sendEmailVerification(Auth.currentUser) - everything works, User Auth.currentUser gets his Email with verification link.
BUT. What if he does not click this link (maybe it went to spam)? He searcehs it, time passes, he maybe switches off the PC or closes the App. And after some time tries again: opens the App, tries to register again...
=> as he enters again the same E-mail he entered when he tried to register for the first time, our createUserWithEmailAndPassword() will give an error (because the User with such E-mail, even though it is not verified, is already in the database) => Auth.currentUser will be NULL(!!!)
=> if now you try to "REsend the verification E-Mail" with sendEmailVerification(Auth.currentUser) - it will not send anything. Because the user is null.
So, the way out of this situation is to generate verficication link based on the E-mail only and send it somehow to the User via E-mail:
https://firebase.google.com/docs/auth/admin/email-action-links#java_2