-
Notifications
You must be signed in to change notification settings - Fork 39
/
Copy pathfacebook.js
executable file
·74 lines (62 loc) · 2.22 KB
/
facebook.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
Accounts.oauth.registerService('facebook');
if (Meteor.isClient) {
Meteor.loginWithFacebook = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
callback = options;
options = null;
}
var credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback);
var fbLoginSuccess = function (data) {
data.cordova = true;
Accounts.callLoginMethod({
methodArguments: [data],
userCallback: callback
});
}
if (typeof facebookConnectPlugin != "undefined" && Meteor.settings) {
facebookConnectPlugin.getLoginStatus(
function (response) {
if (response.status != "connected") {
facebookConnectPlugin.login(Meteor.settings.public.facebook.permissions,
fbLoginSuccess,
function (error) { console.log("" + error) }
);
} else {
fbLoginSuccess(response);
}
},
function (error) { console.log("" + error) }
);
} else {
Facebook.requestCredential(options, credentialRequestCompleteCallback);
}
};
} else {
if (Meteor.settings &&
Meteor.settings.facebook &&
Meteor.settings.facebook.appId &&
Meteor.settings.facebook.secret) {
ServiceConfiguration.configurations.remove({
service: "facebook"
});
ServiceConfiguration.configurations.insert({
service: "facebook",
appId: Meteor.settings.facebook.appId,
secret: Meteor.settings.facebook.secret
});
Accounts.addAutopublishFields({
// publish all fields including access token, which can legitimately
// be used from the client (if transmitted over ssl or on
// localhost). https://developers.facebook.com/docs/concepts/login/access-tokens-and-types/,
// "Sharing of Access Tokens"
forLoggedInUser: ['services.facebook'],
forOtherUsers: [
// https://www.facebook.com/help/167709519956542
'services.facebook.id', 'services.facebook.username', 'services.facebook.gender'
]
});
} else {
console.log("Meteor settings for accounts-facebook-cordova not configured correctly.")
}
}