forked from robfallows/tunguska-accounts-imgur
-
Notifications
You must be signed in to change notification settings - Fork 2
/
apple.js
32 lines (29 loc) · 1.11 KB
/
apple.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
/* global Apple */
Accounts.oauth.registerService('apple');
if (Meteor.isClient) {
const loginWithApple = (options, callback) => {
// support a callback without options
if (!callback && typeof options === 'function') {
callback = options;
options = null;
}
const credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(
callback,
);
Apple.requestCredential(options, credentialRequestCompleteCallback);
};
Accounts.registerClientLoginFunction('apple', loginWithApple);
Meteor.loginWithApple = (...args) => Accounts.applyLoginFunction('apple', args);
} else {
Accounts.addAutopublishFields({
forLoggedInUser: Apple.whitelistedFields.concat(['accessToken', 'expiresAt']).map(
subfield => `services.apple.${subfield}`, // don't publish refresh token
),
forOtherUsers:
// even with autopublish, no legitimate web app should be
// publishing all users' emails
Apple.whitelistedFields
.filter(field => field !== 'email' && field !== 'verified_email')
.map(subfield => `services.apple.${subfield}`),
});
}