2012-09-23 3 views
0

이미 페이스 북에 로그인했지만 자신의 계정에서 내 앱을 삭제 한 사용자가있는 경우 사용자가 이미 내 앱을 다시 입력했을 때만 publish_stream을 묻는 방법 로그인?Facebook + 게시 스트림 만 묻기

감사합니다.

FB.getLoginStatus(function (response) { 
      if (response.status === 'connected') { 
       // the user is logged in and has authenticated your 
       // app, and response.authResponse supplies 
       // the user's ID, a valid access token, a signed 
       // request, and the time the access token 
       // and signed request each expire 
       uid = response.authResponse.userID; 
       accesstoken = response.authResponse.accessToken; 
       SrReferral = '@ViewBag.Referral'; 
       window.fbuserid = uid; 
       var postData = { facebookUID: uid, facebookAccessTok: accesstoken, facebookSrReferral: SrReferral }; 
       $.ajax({ 
        url: '@Url.Action("DisplayGolfers")', 
        type: 'POST', 
        data: postData, 
        dataType: 'html', 
        success: function (responseText) { 
         $("#container").html(responseText); 
        } 
       }); 
      } else if (response.status === 'not_authorized') { 
       // the user is logged in to Facebook, 
       // but has not authenticated your app 
      } else { 
       // the user isn't logged in to Facebook. 
       window.FB.login(function (response) { 
        if (response.authResponse) { 
         uid = response.authResponse.userID; 
         accesstoken = response.authResponse.accessToken; 
         SrReferral = '@ViewBag.Referral'; 
         window.fbuserid = uid; 
         var postData = { facebookUID: uid, facebookAccessTok: accesstoken, facebookSrReferral: SrReferral }; 
         $.ajax({ 
          url: '@Url.Action("DisplayGolfers")', 
          type: 'POST', 
          data: postData, 
          dataType: 'html', 
          success: function (responseText) { 
           $("#container").html(responseText); 
          } 
         }); 
        } else { 
         console.log('User cancelled login or did not fully authorize.'); 
         alert('User cancelled login'); 
        } 
       }, { scope: 'publish_stream' }); 
      }; 
     }); 
    } 

답변

0

귀하의 질문을 오해하고 사용자가 Facebook에서 자신의 계정에서 응용 프로그램을 삭제하더라도 로그인 상태를 유지하기를 원합니다. 이것은 정말로 나쁘고 쉽게 보안 문제가 될 수 있습니다.

사용자가 응용 프로그램을 제거하고 나면 로그인하면 안됩니다!

다음 번에 앱을 방문하기 전에 사용자에게 권한을 묻지 않으려는 경우 (다음 시간) (예 : 시간/일/브라우저 세션/등) 및 프롬프트가 올 정확한 시간 인 경우 모든 방문을 확인하도록 일부 쿠키/세션을 설정하십시오.


당신은 항상 (당신의 응용 프로그램을 제거 할 사용자에 대한 connected을 반환하지 않습니다) 사용자의 신선한 상태를 가져 FB.getLoginStatus에 대한 두 번째 매개 변수를 사용할 수 있습니다.

FB.getLoginStatus(function(response) { 
    // this will be called when the roundtrip to Facebook has completed 
}, true); 

육즙 FB.getLoginStatus documentation

+0

감사의 섹션, 내가 http://developers.facebook.com/docs/reference/javascript/FB.getLoginStatus의 설명서를 읽고 있었다 "페이스 북의 서버로 왕복"를 참조하십시오/상태 중 하나는 사용자가 FB에 로그온했지만 아직 내 사용자가 로그온하는 시나리오 중 하나 인 것으로 생각되는 내 앱을 인증하는 것입니다. 내 앱은 본인의 앱이지만 계정 설정에서 바로 제거 할 수 있습니다. '다른 경우 if (response.status ==='not_authorized ')'. 사용자가 내 앱을 제거 할 때 왜 로그인해서는 안되는 지 잘 모르겠습니다. 내가 틀렸다면 나를 바로 잡아주세요. 감사. – k80sg

+0

@ user415795 글쎄, 일단 사용자가 응용 프로그램을 제거하면 그는 여전히 기술적으로 로그인되어 있지만 더 이상 응용 프로그램 사용자가 아님을 알게되면 로그 아웃 (또는 되돌릴 가능성이 있습니다)해야합니다 . 'FB.getLoginStatus'를 두 번째 매개 변수가'true '와 동일하게 사용하면 Facebook에서 새로운 상태를 가져오고 사용자가 앱에 로그인되어 있지 않다는 사실을 알게됩니다. 두번째 매개 변수없이'FB.getLoginStatus'를 호출하면 사용자와의 연결 상태를 나타내지 않는'authResponse' 캐시됩니다. –