forked from Meteor-Community-Packages/meteor-link-accounts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
link_accounts_client.js
28 lines (27 loc) · 1.05 KB
/
link_accounts_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.tryLinkAfterPopupClosed = function(credentialToken, callback) {
var credentialSecret = OAuth._retrieveCredentialSecret(credentialToken);
Accounts.callLoginMethod({
methodArguments: [{link: {
credentialToken: credentialToken,
credentialSecret: credentialSecret
}}],
userCallback: callback && function (err) {
// Allow server to specify a specify subclass of errors. We should come
// up with a more generic way to do this!
if (err && err instanceof Meteor.Error &&
err.error === Accounts.LoginCancelledError.numericError) {
callback(new Accounts.LoginCancelledError(err.details));
} else {
callback(err);
}
}});
};
Accounts.oauth.linkCredentialRequestCompleteHandler = function(callback) {
return function (credentialTokenOrError) {
if(credentialTokenOrError && credentialTokenOrError instanceof Error) {
callback && callback(credentialTokenOrError);
} else {
Accounts.oauth.tryLinkAfterPopupClosed(credentialTokenOrError, callback);
}
};
};