当我尝试在Firebase Auth中重置密码时,如何捕获“ ERROR_USER_DISABLED”异常?

时间:2019-07-30 10:21:23

标签: exception kotlin firebase-authentication

我有一个Android Kotlin应用程序,需要在其中创建一个登录表单。现在,我正在尝试创建-reset password之类的功能。那很好,但是除了一件小事。我的代码不想捕获ERROR_USER_DISABLED异常。你能告诉我为什么吗?我的代码捕获了除此以外的其他异常。

mAuth.sendPasswordResetEmail(email).addOnCompleteListener { task ->
            if (task.isSuccessful) {
                // everything's okay!
                Toast.makeText(this, "Check your email box!", Toast.LENGTH_LONG).show()
            } else {
                when ((task.exception as FirebaseAuthException).errorCode) {
                    "ERROR_INVALID_EMAIL" -> {
                        mInputLayoutEmail.error = "Email isn't valid!"
                    }
                    // it isn't caught. why?
                    "ERROR_USER_DISABLED" -> {
                        showDialogMessage("Your account has been disabled!")
                    }
                    "ERROR_USER_NOT_FOUND" -> {
                        showDialogMessage("User not found!")
                    }
                }
            }
        }

0 个答案:

没有答案