-
Notifications
You must be signed in to change notification settings - Fork 6
/
client.js
28 lines (25 loc) · 1.04 KB
/
client.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
Accounts.oauth.tryConnectAfterPopupClosed = function(credentialToken, callback) {
var credentialSecret = OAuth._retrieveCredentialSecret(credentialToken) || null;
Meteor.call('connectUserWithFacebook', credentialToken, credentialSecret, function() {
if (!!callback)
callback(arguments);
});
};
Accounts.oauth.credentialRequestForConnectCompleteHandler = function(callback) {
return function (credentialTokenOrError) {
if(credentialTokenOrError && credentialTokenOrError instanceof Error) {
callback && callback(credentialTokenOrError);
} else {
Accounts.oauth.tryConnectAfterPopupClosed(credentialTokenOrError, callback);
}
};
};
Meteor.connectWithFacebook = function(options, callback) {
// support a callback without options
if (! callback && typeof options === "function") {
callback = options;
options = null;
}
var credentialRequestCompleteCallback = Accounts.oauth.credentialRequestForConnectCompleteHandler(callback);
Facebook.requestCredential(options, credentialRequestCompleteCallback);
};