Created
          April 7, 2016 16:08 
        
      - 
      
- 
        Save esperancaJS/3c4f24f928e5fd03863f5e6ba54cb3c1 to your computer and use it in GitHub Desktop. 
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
  | this.FbLogin = function(){ | |
| FB.login(function(response) { | |
| console.log('login response'); | |
| console.log(response); | |
| if(response.status === 'connected'){ | |
| FB.api('/me/permissions', function(response) { | |
| console.log(response); | |
| if(response.data[1].status !== 'granted'){ //email | |
| retryToLogin(); | |
| } | |
| }); | |
| } | |
| // handle the response | |
| }, {scope: 'public_profile,email', auth_type: 'rerequest'}); | |
| } | |
| function retryToLogin(){ | |
| alert("We really need your email :s"); | |
| FB.logout(function(response) { | |
| FB.login(function(response) { | |
| if(response.status === 'connected'){ | |
| FB.api('/me/permissions', function(response) { | |
| console.log(response); | |
| if(response.data[1].status !== 'granted'){ | |
| retryToLogin(); | |
| } | |
| }); | |
| } | |
| }, { | |
| scope: 'public_profile,email', | |
| auth_type: 'rerequest' | |
| }); | |
| }); | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment