2017-01-19 5 views
0

나는 내 웹 사이트에 Google 및 Facebook 로그인 정보를 통합합니다. 그리고 사람이 FB 또는 Google로 로그인 할 수있는 조건을 설정하십시오. 이제 문제는 내 Gmail 계정이 동일한 브라우저에서 열려 있으면 내 Google 로그인 기능이 자동으로 작동한다는 것입니다.모든 페이지에서 전화 할 수있는 Google 로그인 기능 사용하지 않음

function loggedOut(href){ 
    gapi.load('auth2', function() { 
       gapi.auth2.init(); 
    }); 
     setTimeout(function(){ 
     var auth2 = gapi.auth2.getAuthInstance(); 
     auth2.signOut().then(function() { 
      //console.log('User signed out.'); 
      document.location = href; 
     }); 

     }, 2000); 
} 

function onSignIn(googleUser) { 
    var profile = googleUser.getBasicProfile(); 
    var fullName = profile.getName(), 
    imageUrl = profile.getImageUrl(), 
    email = profile.getEmail(), 
    provider = 'Google'; 
    $.ajax({ 
     url: 'includes/google-login.php', 
     type: 'POST', 
     data: { provider: provider, fullName :fullName, imageUrl : imageUrl, email: email }, 
     success: function(data){ 
      console.log(data); 
      if(data == 1){ 
       location.reload(); 
      } else if(data.trim().match("^Entered")){ 
       alert(data); 
       loggedOut('This Page URL'); 
      } 
     } 
    }); 
}; 

$('#log-out').on('click', function(e){ 
    e.preventDefault(); 
    var href = $(this).attr('href'); 
    loggedOut(href); 
}); 

답변

0

var auth2 = gapi.auth2.getAuthInstance();

이것을 login이라고하는 함수 안에 넣고 사용자가 로그인 버튼을 클릭 할 때만 호출하십시오. 그건 자동으로 사용자를 감지 Google을 방지해야합니다. 또는이 줄을 완전히 제거 할 수 있습니다.