Друзья, подскажите.
имею шаблон
<!-- Number Input Form -->
<div v-if="showNumberInput">
<!--<form v-on:submit.prevent="sendOtpForVerification">-->
<form v-on:submit.prevent>
<div class="form-group">
<input type="text" class="form-control form-control-lg" v-model="dataAuth.phone" placeholder="Phone number" required>
</div>
<div class="form-group">
<button type="submit" id="get-sign-in-code" class="btn btn-primary">{{ getSignInCodeButton.text }}</button>
</div>
</form>
</div>
<!-- SMS Verification Form -->
<div v-if="showCodeInput">
<form @submit.prevent="confirmVerification" @submit.enter="confirmVerification">
<div class="form-group">
<input type="text" class="form-control form-control-lg" v-model="dataAuth.code" placeholder="Verification Code" required>
</div>
<div class="form-group">
<button type="submit" @click="confirmVerification" class="btn btn-primary">{{ signInButton.text }}</button>
</div>
</form>
</div>
скрипт
import firebase from 'firebase/compat/app';
export default {
name: "index",
data() {
return {
dataAuth: {
phone: '',
code: '',
},
showNumberInput: true,
showCodeInput: false,
// Buttons
getSignInCodeButton: {
text: 'Get sign in code',
},
signInButton: {
text: 'Sign in',
},
}
},
mounted () {
window.recaptchaVerifier = new firebase.auth.RecaptchaVerifier(
"get-sign-in-code",
{
size: "invisible",
callback: (response) => {
console.log('workrs')
sendOtpForVerification();
},
}
);
},
methods: {
sendOtpForVerification() {
this.showNumberInput = false;
this.showCodeInput = true;
const phoneNumber = this.dataAuth.phone; //user phone number
const appVerifier = window.recaptchaVerifier;
firebase.auth().languageCode = "ru";
firebase.auth()
.signInWithPhoneNumber(phoneNumber, appVerifier)
.then((confirmationResult) => {
// SMS sent. Prompt user to type the code from the message, then sign the
// user in with confirmationResult.confirm(code).
window.confirmationResult = confirmationResult;
//this.$toast.success("Otp sent successfully");
})
.catch((error) => {
// Error; SMS not sent
console.log("Error", error);
});
},
confirmVerification() {
const code = this.dataAuth.code
console.log(confirmationResult)
confirmationResult.confirm(code).then((result) => {
// User signed in successfully.
const user = result.user;
console.log(user);
}).catch((error) => {
console.log("Error", error);
});
}
}
}
по идеи как должно быть. Есть кнопка отправки номера телефона с id get-sign-in-code, которая отправляет капчу и вызывает метод sendOtpForVerification для отправки sms кода на телефон. Но ничего не происходит. Почему? Помогите скорректировать..