The best approach is to use FB.getLoginStatus
instead FB.login
in fbAsyncInit
part, and then based on the current status you can sign in user, or use his credentials. Got something like this:
window.fbAsyncInit = function () {
FB.Event.subscribe('auth.statusChange', function(auth){
if(auth.status==='connected'){
// subscribe to event, and do some magic stuff when status changes
}
});
FB.init({
appId: fb_config_app_id, // App ID from the app dashboard
channelUrl: fb_config_channel, // Channel file for x-domain comms
status: true, // Check Facebook Login status
xfbml: true // Look for social plugins on the page
});
// Load in the user credentials
FB.getLoginStatus(function(response){
if (response.status === 'connected') {
// hey - user is already connected !
} else {
// login user
}
});
}