-
Notifications
You must be signed in to change notification settings - Fork 13
/
client.js
41 lines (38 loc) · 1.31 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
29
30
31
32
33
34
35
36
37
38
39
40
41
Accounts.oauth.tryConnectAfterPopupClosed = function (credentialToken, callback) {
var credentialSecret = OAuth._retrieveCredentialSecret(credentialToken) || null;
var options = {
oauth: {
credentialToken: credentialToken,
credentialSecret: credentialSecret
}
};
Meteor.call("addLoginService", options, function (error) {
if (callback) {
callback(error);
}
});
};
Accounts.oauth.connectCredentialRequestCompleteHandler = function (callback) {
return function (credentialTokenOrError) {
if (credentialTokenOrError && credentialTokenOrError instanceof Error) {
if (callback) {
callback(credentialTokenOrError);
}
} else {
Accounts.oauth.tryConnectAfterPopupClosed(credentialTokenOrError, callback);
}
};
};
var makePascalCased = function (word) {
return word[0].toUpperCase() + word.slice(1).toLowerCase();
};
Meteor.connectWith = function (service, options, callback) {
// Support a callback without options
if (!callback && typeof options === "function") {
callback = options;
options = null;
}
var connectCredentialRequestCompleteCallback = Accounts.oauth.connectCredentialRequestCompleteHandler(callback);
var Service = typeof service === "string" ? Package[service][makePascalCased(service)] : service;
Service.requestCredential(options, connectCredentialRequestCompleteCallback);
};