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

263
Visualizações
firebase (v9) How to get 'isNewUser' info after Google redirect?

I would like to check if the user is new after a Google redirect. Inside the signInWithEmailLink routine this works

let credential = await signInWithEmailLink(auth, email, window.location.href)
const details = getAdditionalUserInfo(credential)
const isNewUser = details.isNewUser

but logging this credential gives UserCredentialImpl and the credential after the redirect OAuthCredential
So this doesn't work

 const redirectResult = await getRedirectResult(auth)
        if(redirectResult) {
            try {
                const credential = GoogleAuthProvider.credentialFromResult(redirectResult);
                console.log('credential', credential)
                const details = getAdditionalUserInfo(credential)
                const isNewUser = details.isNewUser           
            } catch (error) {
                const email = error.email;
                const credential = GoogleAuthProvider.credentialFromError(error);
                console.log('error while signing in with google - getting redirect result', email, credential, error)
            }
        }

with the IDE already complaining "Argument type OAuthCredential is not assignable to parameter type UserCredential" and the error "TypeError: Cannot read properties of undefined (reading 'isAnonymous')"

How can the .isNewUser info be read after the redirect?

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

0

I just realized that the redirectResult is of type UserCredentialImpl so this works

const redirectResult = await getRedirectResult(auth)
        if(redirectResult) {
            try {      
                const details = getAdditionalUserInfo(redirectResult)
                const isNewUser = details.isNewUser
                ...           
            } catch (error) {
                ...
            }
        }

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