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

144
Vistas
How can I fix this issie with logging in users and storing them in a firestore database?

This code i used to store users in firebase.

this.db
        .doc('/users/' + user.uid)
        .set({
          name: user.displayName,
          email: user.email,
        })
        .then(() => console.log('user saved successfully'))
        .catch((reason: any) => console.log('user save failed:', reason));

Users also have a isAdmin property that gets set elsewhere. When I login as a new user, the user gets a name and email.

If i make the user admin i can visit admin only pages. issue is, if i refresh on an admin page i get kicked of the page. I think the issue is the set method, since it doesnt contain the isAdmin property

When I use update instead of set, it works fine when I refresh, but now I cant create new records for new users.

What is the best way to tackle this?

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

You're looking to merge the data in your set call with the existing data (if any), which you can do by specifying set options:

this.db
    .doc('/users/' + user.uid)
    .set({
      name: user.displayName,
      email: user.email,
    }, { merge: true }) // 👈

Also see: https://firebase.google.com/docs/firestore/manage-data/add-data#set_a_document

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