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

136
Visualizações
Auto relaod after login

I have a google login on my website, with an auto reload after the user is correctly logged in.

The problem is every time the user is browsing the website it is reloading the page.

So if he opens an article, it will load the page and the reload the page.

Here is my JS

    function onSuccess(googleUser) {
    var static_url = 'https://www.mywebsite.com/';
    
    gapi.client.load('oauth2', 'v2', function () {
        var request = gapi.client.oauth2.userinfo.get({
            'userId': 'me'
        });
        request.execute(function (resp) {
onclick="signOut();">Sign out</a></h3>';
</b>'+resp.id+'</p><p><b>Name: </b>'+resp.name+'</p><p><b>Email: </b>'+resp.email+'</p><p><b>Gender: </b>'+resp.gender+'</p><p><b>Locale: </b>'+resp.locale+'</p><p><b>Google Profile:</b> <a target="_blank" href="'+resp.link+'">click to view profile</a></p>';
            
            
            $.ajax({
                type: 'POST',
                url: static_url+'/deals/google_login',
                async: false,
                data: {email:resp.email,name:resp.name},
                success: function (result) {
                    $('.msg').removeClass('alert alert alert-danger');
                    $('.lmsg').show();
                    if(result == 'blocked'){
                        signOut();
                        $('.lmsg').addClass('alert alert-danger');
                        $('.lmsg').html('Your account is blocked');
                        setTimeout(function() {
                            $('.lmsg').fadeOut('slow');
                        }, 3000);
                    }else{
                        
                        if( window.localStorage ){
                        if( !localStorage.getItem('firstLoad') ){
                            $('.lmsg').addClass('alert');
                            $('.lmsg').html('Successfully Logged In');
                            localStorage['firstLoad'] = true;
                            $('.lmsg').fadeOut('slow');
                            window.location.reload();
                        }else
                            localStorage.removeItem('firstLoad');
                        }

                    }
                }
            });            
        });
    });
}

If I remove the window.location.reload(); the issue is gone, but user get stuck on the login page, so I really need to reload the page after the user logged in. To redirect it to the front page and load his profile picture, name...

Does any one already face this issue? or have a solution?

Thank you

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