As I navigate my AngularJS website, I am utilizing the Facebook SDK for JavaScript to facilitate registration forms. After successfully logging in and retrieving the necessary data from my first attempt, I proceeded to register and eventually logged out of both the system and Facebook.
When I returned to create a second registration using a different Facebook account, I encountered an unexpected issue. Rather than prompting me to input new login credentials as intended, the SDK automatically used my previous information. Upon investigating, I found that my Facebook status remained 'connected' despite completing a logout process.
This led me to question my assumption about being disconnected after performing a Facebook logout. How can I properly disconnect the initial user to allow for the use of a different Facebook account during subsequent registrations?
For logging in, my code snippet looks like this:
var deferred = $q.defer();
FB.getLoginStatus(function(response) {
if (response.status === 'connected') {
console.log('already logged in.');
deferred.resolve(response);
}
else {
FB.login( function(response) {
if (response.authResponse) {
console.log('response: ' + JSON.stringify(response));
var access_token = response.authResponse.accessToken;
console.log('access token: ' + access_token);
console.log('Welcome! Fetching your information.... ');
deferred.resolve(response);
} else {
console.log('User cancelled login or did not authorize.');
deferred.reject('Error occurred');
}
}, {
scope: 'public_profile, email, user_birthday',
return_scopes: true
});
}
});
return deferred.promise;
And my logout function is implemented as follows:
var deferred = $q.defer();
FB.logout(function(response) {
// I've tried with and without this line of code:
FB.Auth.setAuthResponse(null, 'unknown');
console.log('FB service logged out');
deferred.resolve(response);
});
return deferred.promise;
Despite attempting to follow guidance from sources like this reference, specifically by incorporating
FB.Auth.setAuthResponse(null, 'unknown');
post-logout, I have yet to resolve this ongoing issue.