I need to change user phoneNumber in Authentication, which function should I use?
My code:
// Update the phone number of the user in authentication and database
export async function updateUserPhoneNumber(
email,
newPhone,
password,
clearInputs
) {
try {
const user = auth.currentUser;
if (!user) {
showErrorToast("No user is currently signed in.");
return;
}
// Reauthenticate the user
const credential = EmailAuthProvider.credential(email, password);
await reauthenticateWithCredential(user, credential);
// Update the phone number
await updatePhoneNumber(user, newPhone);
// Update the phone number in the database
const userRef = ref(db, `users/${user.uid}`);
await update(userRef, { phoneNumber: newPhone });
clearInputs();
} catch (error) {
return error;
}
}
I know that PhoneAuthProvider is depricated and docs tells me that I should use verifyPhoneNumber.