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

160
Visualizações
Firebase SignInWIthEmailAndPasswod doesn't work

I'm having issues implementing Login logic using Firebase email and password method. I've done everything according to documentation for 8 and 9 SDK versions but they don't work. To be more specific .then doesn't work. I've implemented register and sign out without any issue, but login doesn't do anything. Here is login:

import firebase from 'firebase/app'
import 'firebase/auth';
import { useHistory } from 'react-router-dom';

...

const loginUser = (email, password) => {
        firebase.auth().signInWithEmailAndPassword(email, password).then((userCredential) => {
            console.log('user', userCredential)
            history.push('/admin')
        })
        .catch((error) => {
            var errorCode = error.code;
            var errorMessage = error.message;
            console.error(errorCode, errorMessage)
        });
    }
}

...

Whatever I try to log in .then() nothing happens, there is also no error. In network tab verifyPassword request is cancelled.

I really don't understand what is wrong there since it should be easy implementation.

Thanks

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

firebase.auth()

is not available in Firebase V9. Make sure to read Docs of Firebase V9. Because Firebase V9 doesn't built-in Object-Oriented Way. It was built with Functional Way.

You can change as

import { initializeApp } from 'firebase/app';
import { getAuth, signInWithEmailAndPassword } from 'firebase/auth';

const firebaseConfig = {
       ////
}
initializeApp(firebaseConfig)

const auth = getAuth()
const loginUser = (email, password) => {
    signInWithEmailAndPassword(auth, email, password).then((userCredential) => {
            console.log('user', userCredential)
            history.push('/admin')
        })
        .catch((error) => {
            var errorCode = error.code;
            var errorMessage = error.message;
            console.error(errorCode, errorMessage)
        });
    }
}

Kindly read the Documentation to your doubts. I would recommend you to watch Net Ninja's Firebase V9 Click here

about 4 years ago · Juan Pablo Isaza Relatório
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