Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions Connectors/Facebook/lib.js
Original file line number Diff line number Diff line change
Expand Up @@ -122,16 +122,19 @@ var profile;
exports.getProfile = function(cbDone) {
if(!profile) {
try {
//Problem: if an error occurred, the profile.json will have error message,
//the correct profile will not be retrieved and a cycle of error is created.
profile = JSON.parse(fs.readFileSync('profile.json'));
return cbDone(null, profile);
} catch (err) {}
}
if(!profile) {
request.get({uri:'https://graph.facebook.com/me?access_token=' + auth.accessToken + '&fields='+allUserFields, json:true},
function(err, resp, profile) {
fs.writeFile('profile.json', JSON.stringify(profile), function(err) {
cbDone(err, profile);
});
if(profile.id) //Solution: if an error occurred, the profile.json will not be created.
fs.writeFile('profile.json', JSON.stringify(profile), function(err) {
cbDone(err, profile);
});
});
} else {
cbDone(null, profile);
Expand Down