小编Luc*_*des的帖子

firebase signInWithPhoneNumber recaptcha 客户端已被删除 0

您好,我正在尝试在不使用 firebaseui 的情况下使用电话号码对用户进行身份验证。

\n\n

我的 html 模板如下所示:

\n\n
<div class="flex center space-items-sides-m m-t-m" dir="ltr">\n    <p-dropdown panelStyleClass="phone-select" [options]="countries" [(ngModel)]="phoneNumber.country" [style]="{\'width\':\'130px\'}" optionLabel="name" [filter]="true" appendTo="body">\n      <ng-template let-item pTemplate="selectedItem">\n        +{{item.value.callingCode}}\n      </ng-template>\n    </p-dropdown>\n    <input type="text" pInputText id="phone" [(ngModel)]="phoneNumber.phone" pKeyFilter="pint">\n  </div>\n  <div class="m-t-l" id="recaptcha-container"></div>\n  <button (click)="sendLoginCode()" class="m-t-l" pButton label="\xd7\xa9\xd7\x9c\xd7\x97 \xd7\xa7\xd7\x95\xd7\x93 \xd7\x90\xd7\x99\xd7\x9e\xd7\x95\xd7\xaa" [disabled]="!phoneNumber.isValid || !isRecaptchaValid()"></button>\n
Run Code Online (Sandbox Code Playgroud)\n\n

我的组件如下所示:

\n\n
 ngOnInit() {\n    this.windowRef = window;\n    this.windowRef.recaptchaVerifier = new firebase.auth.RecaptchaVerifier(\'recaptcha-container\');\n    this.windowRef.recaptchaVerifier.render().then((widgetId) => {\n      this.windowRef.recaptchaWidgetId = widgetId;\n    });\n  }\n\n  isRecaptchaValid() {\n    return (grecaptcha.getResponse(this.windowRef.recaptchaWidgetId).length > 0);\n  }\n\n  sendLoginCode() {\n    this.store.dispatch(new fromStore.SetLoading(true));\n    this.firebaseFunctionsService.getFunction(`userExistence/${this.phoneNumber.e164}`).subscribe(data …
Run Code Online (Sandbox Code Playgroud)

recaptcha firebase typescript firebase-authentication angular

5
推荐指数
1
解决办法
4344
查看次数