Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

165
Vistas
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 Respuestas
Responde la pregunta

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 Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda