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

95
Visualizações
how to insert into database and check if it is already in the database before successful google log in

I want to know how to take the coupon input and check if it is already in the coupons database before successful google log in. (If the coupon is in the coupons database then log in successfully).

const responseGoogle = async (response) => {
        console.log(response)
        try {
            const req = await axios.post(`${process.env.REACT_APP_BASE_URL}/api/v1/login/google/googlelogin`,
                { tokenId: response.tokenId }, { withCredentials: true }
            )
            if (req.status === 200) {
                localStorage.setItem('loginstatus', 'true')
                localStorage.setItem('userprofile', JSON.stringify(response.profileObj))
                history.push('/welcome')
            }
            else {
                alert('err')
            }
        }
        catch (e) {
            (e.response.status === 400 && e.response.data.reason === 'not_domain') ?
                alert('Your email domain is not valid') :
                alert('An error occurred')
        }
    }
return(
<>
<GoogleLogin
                clientId={process.env.REACT_APP_GOOGLE_ID}
                render={renderProps => (
                    <Button onClick={renderProps.onClick} disableElevation disabled={renderProps.disabled} variant="outlined" color="default">
                        <img src={logo} alt="Google Logo" className="login_logo_comp" />  Sign in with Google
                    </Button>
                )}
                buttonText="Login"
                onSuccess={responseGoogle}
                onFailure={failed}
                cookiePolicy={'single_host_origin'}
            />
</>
)

Would adding prompt to take the coupon input work? how to do this? and it should be before user enter google information or after? what other ways to do that?

about 4 years ago · Juan Pablo Isaza
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