-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathclient.js
More file actions
44 lines (37 loc) · 850 Bytes
/
client.js
File metadata and controls
44 lines (37 loc) · 850 Bytes
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
'use strict'
const logins = new Mongo.Collection('logins')
const currentLoginId = new ReactiveVar()
Tracker.autorun(function () {
Meteor.connection._userIdDeps.depend()
Meteor.defer(function () {
const token = localStorage.getItem('Meteor.loginToken')
if (token != null) {
Meteor.call(
'logins_updateLastLogin',
token,
function (e, r) {
currentLoginId.set(r)
}
)
}
})
})
export function subscribe () {
return Meteor.subscribe('logins')
}
export function all () {
return logins.find().fetch()
}
export function current () {
return logins.findOne(currentLoginId.get())
}
export function others () {
return logins.find({
_id: { $ne: currentLoginId.get() },
}).fetch()
}
export function kill (loginId, callback) {
Meteor.call('logins_kill', loginId, function (e, r) {
callback && callback(e, r)
})
}