-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathaccounts-lea.js
29 lines (26 loc) · 992 Bytes
/
accounts-lea.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
/* global Lea */
import { Meteor } from 'meteor/meteor'
import { Accounts } from 'meteor/accounts-base'
Accounts.oauth.registerService('lea')
if (Meteor.isClient) {
const loginWithLea = (options, callback) => {
// support a callback without options
if (!callback && typeof options === 'function') {
callback = options
options = null
}
const credentialRequestCompleteCallback = Accounts.oauth.credentialRequestCompleteHandler(callback)
Lea.requestCredential(options, credentialRequestCompleteCallback)
}
Accounts.registerClientLoginFunction('lea', loginWithLea)
Meteor.loginWithLea = (...args) => Accounts.applyLoginFunction('lea', args)
} else {
Accounts.addAutopublishFields({
// publish all fields including access token, which can legitimately
// be used from the client (if transmitted over ssl or on localhost).
forLoggedInUser: ['services.lea'],
forOtherUsers: [
'services.lea.id', 'services.lea.username'
]
})
}