forked from Meteor-Community-Packages/meteor-link-accounts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlink_accounts_client.js
69 lines (67 loc) · 2.21 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
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
import { Meteor } from 'meteor/meteor'
import { Accounts } from 'meteor/accounts-base'
import { OAuth } from 'meteor/oauth'
import './core-services/facebook'
import './core-services/github'
import './core-services/google'
import './core-services/meetup'
import './core-services/meteor_developer'
import './core-services/twitter'
import './core-services/weibo'
import './community-services/angellist'
import './community-services/apple'
import './community-services/dropbox'
import './community-services/discord'
import './community-services/edmodo'
import './community-services/instagram'
import './community-services/linkedin'
import './community-services/mailru'
import './community-services/qq'
import './community-services/ok'
import './community-services/slack'
import './community-services/spotify'
import './community-services/soundcloud'
import './community-services/twitch'
import './community-services/venmo'
import './community-services/vk'
import './community-services/wechat'
import './community-services/line'
import './community-services/office365'
import './community-services/web3'
Accounts.oauth.tryLinkAfterPopupClosed = function (credentialToken, callback) {
const credentialSecret = OAuth._retrieveCredentialSecret(credentialToken)
Accounts.callLoginMethod({
methodArguments: [
{
link: {
credentialToken: credentialToken,
credentialSecret: credentialSecret
}
}
],
userCallback:
callback &&
function (err) {
// Allow server to 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)
}
}
}