电子邮件不被验证在Firebase [英] Email not being Verified in Firebase

查看:95
本文介绍了电子邮件不被验证在Firebase的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Firebase的 isEmailVerified 方法来验证电子邮件。以下是代码:

I am using Firebase's isEmailVerified method to verify an email. The following is the code:

 protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_verifying);
    FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();
    mAuth=FirebaseAuth.getInstance();
    spinner=(ProgressBar)findViewById(R.id.progressBar);
    spinner.setVisibility(View.GONE);
    Log.e("I am launched","hello");
    if(user.isEmailVerified()==true){
       Log.e("I am here","hello");
        State state= new AccountSettingUp(this);
       state.doAction();
   } else {
        Log.e("Maybe i am here","yes");
       user.sendEmailVerification()
               .addOnCompleteListener(new OnCompleteListener<Void>() {
                   @Override
                   public void onComplete(@NonNull Task<Void> task) {
                       if (task.isSuccessful()) {
                           Log.d("email", "Email sent.");
                       }
                   }
               });
   }

这里, else 代码只能在电子邮件未验证时运行。但是,即使我验证了电子邮件并重新启动该活动,如果语句不是 true ,并且发送电子邮件

Here, the else code should only run when the email is not verified. However, even after I verify the email and restart the activity, the if statement is not true and the email is sent again.

推荐答案

这个行为似乎是Firebase当前版本(10.0.1)中的一个限制,可能是一个错误验证。 此相关问题中也报告了相同的问题。

This behavior appears to be a limitation, possibly a bug, in the current version (10.0.1) of Firebase Authentication. The same issue is reported in this related question.

我尝试做一个 reload()

I tried doing a reload() of the user data after the email verification. That didn't help. As reported in the related question, it seems that a sign-out/sign-in is required to get the new email verification status.

这篇关于电子邮件不被验证在Firebase的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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