gpt4 book ai didi

angular - 确认失败 : First argument "verification Code" must be a valid string

转载 作者:行者123 更新时间:2023-12-03 23:13:24 27 4
gpt4 key购买 nike

this is my error第一个参数“验证 ID”必须是有效字符串。

尝试验证代码时出现此错误,请帮忙

登录.html

<ion-content padding>
<div>
<ion-grid>
<ion-label style="font-size: 20px;"> Please enter your phone number </ion-label>
<ion-row justify-content-center>
<div *ngIf="!windowRef.confirmationResult">
<div [hidden]="user" style="margin-top:35px;">
<ion-item>
<ion-input type="tel" maxlength="10" [(ngModel)]="contactNumber" placeholder="Enter Your Phone Number" clearInput required></ion-input>
</ion-item>
</div>

<button style="background-color: #3880ff; width: 135px;height: 40px;border-radius:25px;font-size: 20px;margin: 35px;color: white;" type="submit" (click)="checkeUserExist()">Submit</button>
</div>

<div id="recaptcha-container"></div>

<div *ngIf="windowRef.confirmationResult">
<hr>
<label for="code">Enter your Verification Code Here</label>
<input type="number" name="code" [(ngModel)]="verificationCode"><br><br><br><br>

<button style="background-color: #3880ff; width: 70px;height: 28px;" full type="submit" (click)="verifyLoginCode()">Verify</button><br><br><br>
<ion-label style="font-size: 18px;"> Resend code Again ! </ion-label><br><br>
<button style="background-color: #3880ff; width: 100px;height: 32px;" full type="submit" (click)="sendLoginCode(contactNumber)">Resend code</button>
</div>
</ion-row>
</ion-grid>
</div>
</ion-content>

登录.ts
ngOnInit() {
this.windowRef = this.win.windowRef;
this.windowRef.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('recaptcha-container', {
//'type' : 'image',
'size' : 'invisible',
//'badge': 'inline'
});
//this.windowRef.recaptchaVerifier.render();
}

sendLoginCode(contactNumber) {
const appVerifier = this.windowRef.recaptchaVerifier;
const num = "+91" + contactNumber;

firebase.auth().signInWithPhoneNumber(num, appVerifier)
.then(result => {
this.windowRef.confirmationResult = result;
})
.catch( error => console.log(error) );
}

verifyLoginCode() {
this.windowRef.confirmationResult
.confirm(this.verificationCode)
.then( result => {
this.user = result.user;

this.nav.navigateForward('addPatient');
})
.catch( error => console.log(error, "Incorrect code entered?"));
}

checkeUserExist() {
var self = this;
this.doctorUserCollection = this.db.collection('DoctorList').ref.where('contactNumber', '==', self.contactNumber)
.get()
.then(function(querySnapshot) {
if(querySnapshot.empty) {
self.nav.navigateForward(['/createAccount', { id: self.contactNumber }]);
}
else {
querySnapshot.forEach(function(doc) {
self.sendLoginCode(doc.data().contactNumber);
localStorage.setItem('id', doc.data().uid);
})
}
})

}

请告诉我如何解决这个问题

现在,您需要发送验证码来登录。

我得到了验证码并验证它然后错误来了。

LoginPage.html:32 ERROR L 

{
code: "auth/argument-error",
message: "confirm failed: First argument "verificationCode" must be a valid string.",
ngDebugContext: DebugContext_,
ngErrorLogger: ƒ
}

最佳答案

<input type="number" name="code" [(ngModel)]="verificationCode"><br><br><br><br>

类型 输入的是“数字”。请删除 type 属性以使其工作。

编辑:
否则,您可以在调用 'confirm()' 时将 verifyCode 解析为字符串
this.windowRef.confirmationResult
.confirm(this.verificationCode) <-- parse to string

关于angular - 确认失败 : First argument "verification Code" must be a valid string,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/55121477/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com