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

203
Vistas
How to check If registered user when login with google using firebase in react js?

i want to check if the person logged in with Google account, has registered before or not to save to Firestore. Is there any way to check?

 const ggProvider = new GoogleAuthProvider();

 const handleGgLogin = async () => {
    const { user } = await signInWithPopup(auth, ggProvider);

    const collectionRef = collection(db, "Account");
    const payload = {
      displayName: user.displayName,
      email: user.email,
      photoUrl: user.photoURL,
      uid: user.uid,
    };
    await addDoc(collectionRef, payload);
  };
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're looking for the UserInfo.providerId field of the User object.

Something like this:

onAuthStateChanged(auth, (user) => {
  if (user) {
    // User is signed in, see docs for a list of available properties
    // https://firebase.google.com/docs/reference/js/firebase.User
    const uid = user.uid;

    // Show the provider(s) that the user is signed in with
    user.providerData.forEach((userInfo) => { // 👈
      console.log(userInfo.providerId);       // 👈
    })

    // ...
  }
});

You need the loop, since a user can be signed in with multiple providers at the same time. The provider string for Google is google.com (source).

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