OTP 验证时使用电子邮件和密码创建用户

问题描述 投票:0回答:1

在 Firebase 身份验证中验证 OTP 时,如何使用电子邮件和密码创建用户帐户?我提供了我尝试使用电子邮件和密码创建用户的代码片段。请为我提供解决方案

private fun signInWithPhoneAuthCredential(
    credential: PhoneAuthCredential,
    name: String,
    email: String,
    number: String,
    password:String
) {
    mAuth.signInWithCredential(credential)
        .addOnCompleteListener(requireActivity()) { task ->
            if (task.isSuccessful) {
                // Sign in success, update UI with the signed-in user's information
               // mAuth.currentUser?.verifyBeforeUpdateEmail(email)
                homeViewModel.setUserData(mAuth.currentUser?.uid.toString(),name,email,number)
                //PhoneAuthProvider.getCredential()
                mAuth.createUserWithEmailAndPassword(email,password)
                val intent = Intent(requireActivity(), HomeActivity::class.java)
                startActivity(intent)
            } else {
                Toast.makeText(requireActivity(), "OTP is invalid", Toast.LENGTH_SHORT).show()
            }
        }
}
android firebase kotlin firebase-authentication
1个回答
0
投票

Firebase 的内置电子邮件+密码登录提供商不使用 OTP,但您可以单独设置多重身份验证 (MFA)。

如果您想将 MFA 与 Firebase 结合使用,请按照文档使用 SMSTOTP 进行设置。

© www.soinside.com 2019 - 2024. All rights reserved.