I have this script that I put on the head section of my html:
<script>
function goLogIn(){
alert("go login");
window.location.href = "{{ path('_security_check') }}";
}
function onFbInit() {
if (typeof(FB) != 'undefined' && FB != null ) {
alert('here')
FB.Event.subscribe('auth.statusChange', function(response) {
if (response.session || response.authResponse) {
alert("login");
setTimeout(goLogIn, 500);
} else {
alert('logout');
window.location.href = "{{ path('_security_logout') }}";
}
});
}
}
</script>
So the alert box here is printed out. However I tried logging in and logging out, but none of the login or logout is triggered. Any idea why?
Here's how I initialized the facebook button:
<!-- inside a twig template -->
{{ facebook_initialize({'xfbml': true, 'fbAsyncInit': 'onFbInit();'}) }}
{{ facebook_login_button({'autologoutlink': true, 'label': 'Log in using Facebook'}) }}