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

137
Visualizações
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 Respostas
Responde à pergunta

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 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