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

146
Visualizações
Firebase - check if user created with Google Account is signing up or logging in?

I'm trying to create a web application, where you can log-in and register an account with a google account. I have managed to make it so they can log-in with the signInWithPopup(provider), but not sure how to Implement the sign-up. Any suggestions? or know of any functions in firebase i can use?

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

0

There aren't any separate methods to login and sign up when using Google Sign-In or any other provider. If a user with that credential exists then user will be logged in else a new user account will be created. You can then use additionalUserInfo.isNewUser property from the result received from signInWithPopUp method to check if the user is new.

firebase.auth().signInWithPopup(provider).then(function (result) {
  const {additionalUserInfo: {isNewUser}} = result;

  console.log(isNewUser ? "This user just registered" : "Existing User")
})

For the new Modular SDK (V9.0.0+), the same can be written as:

import { signInWithPopup, getAdditionalUserInfo } from "firebase/auth"

const result = await signInWithPopup(auth, googleProvider);

// Pass the UserCredential   
const { isNewUser } = getAdditionalUserInfo(result)    
about 4 years ago · Juan Pablo Isaza Relatório

0

So far, as I understood, you have two options to log in to your website: one is to make a local username/password account on your website, and the other option is to use your google account. I suppose the best way would be to check if the Google account is linked to any existing user using additionalUserInfo.isNewUser, and then linking up your google account with the account that is created via your website locally by following this article: https://firebase.google.com/docs/auth/web/account-linking?hl=lt

about 4 years ago · Juan Pablo Isaza Relatório

0

Once you have Firebase dependency inside your application. You can use createUserWithEmailAndPassword method to do that.

firebase
.auth()
.createUserWithEmailAndPassword("email@domain.com", "123123")
.then(data => {
    data.user.updateProfile({
        displayName: this.form.name
    }).then(() => {});
})
.catch(err => {
    this.error = err.message;
});
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