Firebase - 电子邮件验证邮件不工作 - 发生内部错误。 [USER_NOT_FOUND] [英] Firebase - Email Verification Mail Not Working - An internal error has occurred. [ USER_NOT_FOUND ]

查看:156
本文介绍了Firebase - 电子邮件验证邮件不工作 - 发生内部错误。 [USER_NOT_FOUND]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在成功注册用户之后发送验证邮件。这给了我错误发生了内部错误。 [USER_NOT_FOUND] 。这是我现在的代码 -

  public void signUpUser(View view){

EditText mailEditText =(EditText)findViewById(R.id.editText);
EditText pwdEditTet =(EditText)findViewById(R.id.editText2);


String email = mailEditText.getText()。toString();
String password = pwdEditTet.getText()。toString();

Log.d(Info,email);
Log.d(Info,密码);

mAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(this,new OnCompleteListener< AuthResult>(){
@Override
public void onComplete(@NonNull Task< AuthResult> task ){
try {
AuthResult result = task.getResult();

Log.d(注册,createUserWithEmail:onComplete:+ task.isSuccessful() );


//如果登录失败,向用户显示一条消息,如果登录成功
//将通知auth状态监听器,逻辑处理
//用户名可以在监听器中处理
if(!task.isSuccessful()){
Toast.makeText(MainActivity.this,R.string.auth_failed,
Toast.LENGTH_SHORT).show();
} else {
Log.d(注册,发送验证邮件);
//发送验证邮件
// FirebaseUser user = FirebaseAuth.getInstance()。getCurrentUser();

mAuth.getCurrentUser()。sendEmailVerification()
.addOnCompleteListener(new OnCompleteListener< Void>(){
@Override
public void onComplete(@NonNull Task< ();
if(task.isSuccessful()){
Log.d(Email Sent,Verification Email sent。);
} else {
Log.d(Email Sent,task.getException()。getLocalizedMessage());
}
}
});

} catch(Exception e){
Toast.makeText(MainActivity.this,R.string.user_exist,Toast.LENGTH_SHORT).show();
Log.e(Exception,e.getLocalizedMessage());
}
}
});

$ / code>

这里是打印的日志 -

  10-11 10:10:50.372 31518-31518 / au.com.savedme D /注册:正在发送验证邮件
10-11 10:10:51.438 31518-31518 / au.com.savedme D /电子邮件已发送:发生内部错误。 [USER_NOT_FOUND]
10-11 10:11:00.429 31518-31538 / au.com.savedme W / DynamiteModule:未找到com.google.firebase.auth的本地模块描述符类。

请看一下,让我知道如果我在这里做错了什么。

解决方案

我也有同样的问题,我发现背后的原因是,如果你正在尝试使用相同的用户,创建并从Firebase控制台中删除它,它将无法正常工作。

尝试使用新的电子邮件地址,你没有试过一次,它会工作。 p>


请注意, createUserWithEmailAndPassword()不仅创建用户
,而且如果成功,用户。当创建和
登录时,如果有一个现有的登录用户,出现
是与注销和清除缓存相关的Firebase bug r
前一个用户。

通过调用,我可以使您的代码适用于以前登录的
用户。 href =https://developers.google.com/android/reference/com/google/firebase/auth/FirebaseAuth#signOut() =nofollow noreferrer> signOut()

之前 createUserWithEmailAndPassword()


参考资料

I am trying to send a verification email after successful registration of user. Which gives me the error An internal error has occurred. [ USER_NOT_FOUND ]. This is the code I have at present -

public void signUpUser(View view){

    EditText mailEditText = (EditText) findViewById(R.id.editText);
    EditText pwdEditTet = (EditText) findViewById(R.id.editText2);


    String email = mailEditText.getText().toString();
    String password = pwdEditTet.getText().toString();

    Log.d("Info",email);
    Log.d("Info",password);

    mAuth.createUserWithEmailAndPassword(email,password).addOnCompleteListener(this, new OnCompleteListener<AuthResult>() {
        @Override
        public void onComplete(@NonNull Task<AuthResult> task) {
            try {
                AuthResult result = task.getResult();

                Log.d("Sign up", "createUserWithEmail:onComplete:" + task.isSuccessful());


                // If sign in fails, display a message to the user. If sign in succeeds
                // the auth state listener will be notified and logic to handle the
                // signed in user can be handled in the listener.
                if (!task.isSuccessful()) {
                    Toast.makeText(MainActivity.this, R.string.auth_failed,
                            Toast.LENGTH_SHORT).show();
                }else{
                    Log.d("Sign up", "Sending verification email");
                    // Sending the verification email
                    //FirebaseUser user = FirebaseAuth.getInstance().getCurrentUser();

                    mAuth.getCurrentUser().sendEmailVerification()
                            .addOnCompleteListener(new OnCompleteListener<Void>() {
                                @Override
                                public void onComplete(@NonNull Task<Void> task) {
                                    if (task.isSuccessful()) {
                                        Log.d("Email Sent", "Verification Email sent.");
                                    }else{
                                        Log.d("Email Sent",task.getException().getLocalizedMessage());
                                    }
                                }
                            });
                }
            } catch (Exception e){
                Toast.makeText(MainActivity.this,R.string.user_exist,Toast.LENGTH_SHORT).show();
                Log.e("Exception",e.getLocalizedMessage());
            }
        }
    });
}

and here is the log which is getting printed -

10-11 10:10:50.372 31518-31518/au.com.savedme D/Sign up: Sending verification email
10-11 10:10:51.438 31518-31518/au.com.savedme D/Email Sent: An internal error has occurred. [ USER_NOT_FOUND ]
10-11 10:11:00.429 31518-31538/au.com.savedme W/DynamiteModule: Local module descriptor class for com.google.firebase.auth not found.

Please have a look and let me know in case I am doing anything wrong here.

解决方案

I also had the same issue, and the reason i found behind this is, if you are trying this code with same user which you have already created and then deleted it from firebase console, it will not work.

Try with new email address which you have not tried a single time, and it will work.

Note that createUserWithEmailAndPassword() not only creates the user, but also, if successful, signs the user in. When the creation and sign-in occurs when there is an existing signed-in user, there appears to be a Firebase bug related to signing out and clearing the cache for the previous user.

I was able to make your code work for a previously signed-in and later deleted user by calling signOut() before createUserWithEmailAndPassword().

reference

这篇关于Firebase - 电子邮件验证邮件不工作 - 发生内部错误。 [USER_NOT_FOUND]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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