I am working on a simple registration. I planned to use email to create an account, the problem is upon submission of form, the phone number also signed in as new user.
How can I prevent that from happening? What I only need to use is the send otp feature.
sendOTP() {
var self = this
const phoneNumber = '+' + this.phone;
const appVerifier = window.recaptchaVerifier;
firebase.auth().signInWithPhoneNumber(phoneNumber, appVerifier)
.then((confirmationResult) => {
window.confirmationResult = confirmationResult;
self.otpSent = true
}).catch((error) => {
self.errorMsg = error.code + ': ' + error.message;
});
},
register() {
var self = this
const code = this.otp;
window.confirmationResult.confirm(code).then((result) => {
console.log(result)
firebase.auth().createUserWithEmailAndPassword(this.email, this.password)
.then((userCredential) => {
firebase.database().ref('users').set({
email: this.email,
name: this.name,
password: this.password,
phone: this.phone,
userCredential: userCredential
}, (error) => {
if (error) {
// The write failed...
self.errorMsg = error.message
} else {
self.$router.push('/dashboard')
}
});
})
.catch((error) => {
self.errorMsg = error.message
});
}).catch((error) => {
self.errorMsg = error.message;
});
}
from Firebase: Send OTP but disable sign in using phone number
No comments:
Post a Comment