After pressing the logout button on my site, I am still unable to keep a user logged out. Although they are redirected to the login page, the updateButton function is called again with the same credentials causing them to be logged back in. Despite trying various approaches, the issue persists. It seems that there may be errors in the way I have implemented the updateButton function below, and the FB.logout() method is not working correctly either as indicated by the error message "FB.logout called without an access token" in the console.
$(function(){
var button;
window.fbAsyncInit = function(){
FB.init({
appId : 'myAppId',
status : true,
cookie : true,
xfbml : true,
oauth : true
});
function updateButton(response) { // Uncertain about correctness of this function
console.log("Update Button Fired.");
console.log(response);
button = document.getElementById('fb-auth');
if(response.status === 'connected') {
FB.api('/me', function(info) {
login(response, info);
});
} else {
FB.login(function(response) {
if(response.status === 'not_authorized') {
FB.api('/me', function(info) {
login(response, info);
});
} else {
}
}, {scope: 'email, user_birthday, user_about_me'});
}
}
FB.getLoginStatus(updateButton);
FB.Event.subscribe('auth.statusChange', updateButton);
};
(function() {
var e = document.createElement('script');
e.async = true;
e.type = 'text/javascript';
e.src = document.location.protocol + '//connect.facebook.net/en_US/all.js';
document.getElementById('fb-root').appendChild(e);
})();
function login(response, info){
console.log('login Showloader called');
if (response.authResponse) {
var accessToken = response.authResponse.accessToken;
$.post("/web/register/faceBookRegistration", {data: info, accessTokenValue: accessToken}).done(function(data) {
if(typeof(data) !== undefined) {
window.location = "/web/login/loadViewFaceLogin";
}
});
}
}
function logout(response){
FB.logout(function(response){
console.log("User is now logged out");
});
}
});
My logout function may also not be functioning correctly:
function logout(response){
FB.logout(function(response){
console.log("User is now logged out");
});
}
The error "FB.logout called without an access token" appearing in the console may indicate issues with this function. What could be causing this?