Firebase中是否有一种方法可以验证电子邮件是否经过验证? [英] Is there a way in firebase to get if email is verified?

查看:38
本文介绍了Firebase中是否有一种方法可以验证电子邮件是否经过验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

现在我正在这样做:

firebase.auth().onAuthStateChanged((user) => {
    if (!user.emailVerified) {
      //Something
    }
});

但是,问题是我在多个页面中添加了此代码块,并且每当身份验证发生更改时(用户登录或注销),它都会调用所有这些功能,并且会影响其他代码!

But, the problem is I have added this block of code in multiple pages and whenever the authentication changed (user logged in or logged out) It calls all those functions and that effects other code!

因此,如果没有验证用户的电子邮件,我们是否可以通过任何方式获得-不使用"onAuthStateChanged()"

推荐答案

您在页面中的任何位置都可以执行以下操作:

Anywhere in your page you can do:

firebase.auth().currentUser.emailVerified

确定当前状态.您只需要 onAuthStateChanged()即可监视状态何时更改.

To determine the current state. You only need onAuthStateChanged() to monitor when the state changes.

这篇关于Firebase中是否有一种方法可以验证电子邮件是否经过验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆