-
Notifications
You must be signed in to change notification settings - Fork 22
/
accounts-imgur.js
54 lines (48 loc) · 1.39 KB
/
accounts-imgur.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
'use strict';
/**
* Register this service (boilerplate).
*/
Accounts.oauth.registerService('imgur');
/**
* Client functionality (boilerplate).
*/
if (Meteor.isClient) {
Meteor.loginWithImgur = function(options, callback) {
/**
* support (options, callback) and (callback)
*/
if (!callback && typeof options === "function") {
callback = options;
options = null;
}
/**
*
*/
var credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback);
Imgur.requestCredential(options, credentialRequestCompleteCallback);
};
/**
* Server functionality (boilerplate).
* Ensures sanity of published user object.
*/
} else {
Accounts.addAutopublishFields({
forLoggedInUser: _.map(
/**
* Logged in user gets whitelisted fields + accessToken + expiresAt.
*/
Imgur.whitelistedFields.concat(['accessToken', 'expiresAt']), // don't publish refresh token
function(subfield) {
return 'services.imgur.' + subfield;
}),
forOtherUsers: _.map(
/**
* Other users get whitelisted fields without emails, because even with
* autopublish, no legitimate web app should be publishing all users' emails.
*/
_.without(Imgur.whitelistedFields, 'email', 'verified_email'),
function(subfield) {
return 'services.imgur.' + subfield;
})
});
}