Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

300
Visualizações
Firebase : Not able to link phone number with other AuthProviders javascript

I have implemented emailpassword, google and facebook sign in on my web app. But in previous version phone based signin was also there which I had to remove. So I want the previous users to be linked with other options.

I am trying to link phone number to password based account.

enter image description here

Below code is working and the linking is working perfectly but the problem is I want the user to be signed in with password based account and not the phone number based.

enter image description here Below is the error that I am getting.

signInWithCredential failed: First argument "credential" must be a valid credential.'

async function codeVerification(verificationId, verificationCode){

  try {
   const credential = firebase.auth.PhoneAuthProvider.credential(verificationId, verificationCode)

   const prevUser = auth.currentUser;

   // prevUser.linkWithCredential(credential);

   auth.signInWithCredential(credential)
   .then(user => {
    const secondUser = user.credential;
    auth.currentUser.delete()
    .then(() => {
      return prevUser.linkWithCredential(credential);
    })
    .then(() => {
      console.log(secondUser);
      auth.signInWithCredential(secondUser);
      //this is the step where I am getting error I guess, because I am signing in with phonenumber but how to store current credentials of user

    })
  });


 } catch (error) {

 }
}

I want the user to be signin with the password based account only not with the phone number. How can I implement this correctly?

Thanks

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda