-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathdeezer.js
34 lines (31 loc) · 1.19 KB
/
deezer.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
Accounts.oauth.registerService('deezer');
if (Meteor.isClient) {
const loginWithDeezer = function (options, callback) {
// support a callback without options
if (!callback && typeof options === "function") {
callback = options;
options = null;
}
var credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback);
Deezer.requestCredential(options, credentialRequestCompleteCallback);
};
Accounts.registerClientLoginFunction('deezer', loginWithDeezer);
Meteor.loginWithDeezer = function () {
return Accounts.applyLoginFunction('deezer', arguments);
};
} else {
Accounts.addAutopublishFields({
forLoggedInUser: _.map(
// publish access token since it can be used from the client
Deezer.whitelistedFields.concat(['accessToken', 'expiresAt']),
function (subfield) {
return 'services.deezer.' + subfield;
}),
forOtherUsers: _.map(
// even with autopublish, no legitimate web app should be publishing all users' emails
_.without(Deezer.whitelistedFields, 'email', 'id', 'name', 'firstname', 'lastname'),
function (subfield) {
return 'services.deezer.' + subfield;
})
});
}