0
我正在嘗試將我的電話號碼與我的電子郵件密碼身份驗證相關聯。所以我建立我的註冊使用以下步驟:Firebase電話身份驗證和鏈接
- 用戶輸入電子郵件地址和密碼。
- 然後我打電話
firebase.auth().createUserWithEmailAndPassword(values.email, values.password)
- 然後我需要經常賬戶與手機號碼聯繫起來,所以我使用
firebase.auth().currentUser.linkWithPhoneNumber("+xxxxxxxxxx", xxx)
不過,我看不出有任何的連接。 2個帳戶在我的Firebase控制檯中創建,當前用戶只在他的詳細信息中包含電話號碼。當我再次用電子郵件和密碼登錄並檢查用戶的詳細信息時,電話號碼不存在!
請在下面找到我的代碼:
onSubmit(values) {
this.props.firebase.auth().createUserWithEmailAndPassword(values.email, values.password).then((user) => {
//send recaptchaverifier
window.recaptchaVerifier.verify();
}).catch((error) => {
console.log(error);
});
}
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier('submit-button', {
'size': 'invisible',
'callback': function(response){
//called when we call "window.recaptchaverifier.verify() in
//onSubmit function
var xxx = window.recaptchaVerifier;
this.props.firebase.auth().currentUser.linkWithPhoneNumber("+xxxxxxxx", xxx)
.then((verificationId) => {
console.log('inside');
console.log(resp);
var verificationCode = window.prompt('Please enter the verification ' +
'code that was sent to your mobile device.');
return firebase.auth.PhoneAuthProvider.credential(resp.verificationId,
verificationCode);
}).then((phoneCredential) => {
console.log("RESULT OF AUTH", phoneCredential);
console.log("USER INFO: ", this.props.firebase.auth().currentUser);
return this.props.firebase.auth().signInWithCredential(phoneCredential)
}).catch((error) => {
console.log("ERRORS: ", error);
}).catch((error) => {
console.log("ERROR", error)
});
}.bind(this)
});