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

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

问题描述

我第一次使用firebase phone auth,我看到验证码验证必须按照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?)
  // ...
});


推荐答案

无法删除验证码验证默认身份验证

使用匿名身份验证,以避免出现 captcha 字母。另外匿名身份验证 Firebase身份验证<更简单默认身份验证。

Use anonymous authentication to avoid captcha letters to appear. Also anonymous authentication is more simpler than Firebase Authentication default authentication.

用法:

firebase.auth().signInAnonymously().catch(function(error) {
  // Handle Errors here.
  var errorCode = error.code;
  var errorMessage = error.message;
  // ...
});

详情请参阅此官方文档: https://firebase.google.com/docs/auth/web/anonymous-auth

For details please follow this official documentation : https://firebase.google.com/docs/auth/web/anonymous-auth

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

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