简体   繁体   English

如何检查用户 email 在没有 currentUser 的情况下是否在 firebase 中得到验证

[英]how to check is user email verified or not in firebase without currentUser

In my app I am facing a situation in which I have email of user but not have password, so I can't log in and can't get Firebase auth.currentUser I want to know is user email verified or not before sending password reset link because after reset password user email will be verified but i don't have currentUser so can't use curruser.isEmailVerified在我的应用程序中,我面临这样一种情况,我有 email 用户但没有密码,所以我无法登录也无法获得 Firebase auth.currentUser 我想知道用户 email 在发送密码重置之前是否经过验证链接因为重置密码后用户 email 将被验证但我没有 currentUser 所以不能使用 curruser.isEmailVerified

How can I check it?我怎样才能检查它?
Is Firebase cloud functions usable here? Firebase云函数在这里可以用吗?

Explanation: User is not logged in, user forgot password and user want to reset password but I want to know is user is verified or not because at sign up time I am sending verification link and store that user in my database if email is verified but there is no assurity that user will click on that link but user will be authenticated whether user click on link or not but verification is not assured now that unverified user try to reset password then firebase allow user to do that send email to user to reset password if user reset password then now user is verified but I can't store that user in my data because I can't distinguish verified user and unverified user I want to store that unverified user after reset password is done说明:用户未登录,用户忘记密码,用户想重设密码,但我想知道用户是否已验证,因为在注册时我发送验证链接并将该用户存储在我的数据库中,如果 email 已验证但无法保证用户会点击该链接,但无论用户是否点击链接,用户都将通过身份验证,但现在无法保证验证,因为未经验证的用户尝试重置密码,然后 firebase 允许用户这样做发送 email 给用户重置密码如果用户重置密码,那么现在用户已通过验证,但我无法将该用户存储在我的数据中,因为我无法区分已验证用户和未验证用户我想在重置密码完成后存储未验证用户

If you are planning to send verification email from Firebase Client SDKs then you'll have to login the user and you should have access to email verified property from that.如果您计划从 Firebase 客户端 SDK 发送验证 email,那么您必须登录用户,并且您应该可以从中访问 email 验证属性。 If you just need another way to check if user's email is verified without logging in user, then you can use Admin SDK with Cloud functions:如果您只需要另一种方法来检查用户的 email 是否在不登录用户的情况下得到验证,那么您可以使用具有云功能的Admin SDK

getAuth()
  .getUser(uid)
  .then((userRecord) => {
    console.log(userRecord)
  })
  .catch((error) => {
    console.log('Error fetching user data:', error);
  });

Here userRecord will contain information about user's email verification.这里userRecord会包含用户email验证的信息。


Then you can use generatePasswordResetLink() to create a password reset link but you'll have to setup a custom email service to send emails from a Cloud function.然后您可以使用generatePasswordResetLink()创建密码重置链接,但您必须设置自定义 email 服务才能从 Cloud function 发送电子邮件。


Also, if user can receive password reset link that means they have access to the email and hence email is verified with that.此外,如果用户可以收到密码重置链接,则意味着他们可以访问 email,因此可以验证 email。 One can simply use Firebase Auth REST API to request a verification email or password reset email bypassing such checks.可以简单地使用Firebase Auth REST API请求验证 email 或密码重置 email 绕过此类检查。 If you strictly want to prevent anyone getting password reset links from Firebase client SDKs you might have to run your custom logic with some additional credentials.如果您确实想阻止任何人从 Firebase 客户端 SDK 获取密码重置链接,您可能必须使用一些额外的凭据运行您的自定义逻辑。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何在客户端验证email是否在firebase中验证? - How to check if email is verified in firebase on client side? 如何在 Firebase 身份验证上区分电子邮件验证用户和非验证用户? - How to distinguish email-verified user from non-verified user on Firebase Authentication? email未验证时如何注销用户,Firebase Auth - How to sign out the user when the email is not verified, Firebase Auth 如何在验证其 email 后重定向 flutter 中的用户? - How to redirect a user in flutter after verified their email? 如何在不请求的情况下在firebase-auth中首次加载时获取currentUser - How to get currentUser on first load in firebase-auth without requesting Firebase 仪表板组 email 已验证 - Firebase Dashboard set email verified Firebase Authentication ( Email & Password ) 如何查看现有用户 - Firebase Authentication ( Email & Password ) how to check existing user Firebase Auth,email验证不创建用户? - Firebase Auth, email verification without creating a user? firebase 可以为特定用户提供多少次“currentUser.getIdToken() 和 verifyIdToken()”请求? - How many times can firebase serve, the "currentUser.getIdToken() and verifyIdToken()" requests, for the particular user? email 未验证 - email is not verified
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM