如何使用 javascript 从 Firebase 电话身份验证中删除验证码验证? [英] How to remove captcha verification from Firebase phone auth using javascript?

查看:19
本文介绍了如何使用 javascript 从 Firebase 电话身份验证中删除验证码验证?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我第一次使用 firebase 电话身份验证,我看到必须按照 firebase 官方文档进行验证码验证.虽然它有一个很好的目的,但有时当它开始询问路标、桥梁和所有东西时,它对用户体验来说变得非常糟糕.有没有办法在得到用户号后直接跳到验证码?根据文档,下面提到了代码.谢谢.

I am using firebase phone auth for the very first time and I see captcha verification is must proceed with the process, as per firebase official documentation. Though it serves a good purpose, but sometimes it becomes very bad for the user experience when it starts asking about the road signs, bridges and all. Is there a way to directly skip to the verification code right after getting user's number? As per the documentation, the code is mentioned below. Thanks.

var phoneNumber = getPhoneNumberFromUserInput();
var appVerifier = window.recaptchaVerifier;
firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
    .then(function (confirmationResult) {
      // SMS sent. Prompt user to type the code from the message, then sign the
      // user in with confirmationResult.confirm(code).
      window.confirmationResult = confirmationResult;
    }).catch(function (error) {
      // Error; SMS not sent
      // ...
});

var code = getCodeFromUserInput();
confirmationResult.confirm(code).then(function (result) {
  // User signed in successfully.
  var user = result.user;
  // ...
}).catch(function (error) {
  // User couldn't sign in (bad verification code?)
  // ...
});

推荐答案

在身份验证设置中使用 isAppVerificationDisabledForTesting = TRUE 作为以下给定的片段:

Use isAppVerificationDisabledForTesting = TRUE in auth settings as the below given snippet:

Auth.auth().settings.isAppVerificationDisabledForTesting = TRUE

详情请查看以下官方信息:

Please check the below official information for more details:

JavaScript - https://firebase.google.com/docs/reference/js/firebase.auth.AuthSettings

JavaScript - https://firebase.google.com/docs/reference/js/firebase.auth.AuthSettings

SDK 参考 - https://firebase.google.com/docs/auth/ios/phone-auth#integration-testing

这篇关于如何使用 javascript 从 Firebase 电话身份验证中删除验证码验证?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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