mirror of
https://github.com/overleaf/overleaf.git
synced 2024-10-31 21:21:03 -04:00
33 lines
975 B
CoffeeScript
33 lines
975 B
CoffeeScript
Settings = require('settings-sharelatex')
|
|
logger = require("logger-sharelatex")
|
|
Async = require('async')
|
|
|
|
UserSessionsRedis = require('../../../../app/js/Features/User/UserSessionsRedis')
|
|
|
|
# rclient = redis.createClient(Settings.redis.web)
|
|
rclient = UserSessionsRedis.client()
|
|
|
|
module.exports =
|
|
|
|
getUserSessions: (user, callback=(err, sessionsSet)->) ->
|
|
rclient.smembers UserSessionsRedis.sessionSetKey(user), (err, result) ->
|
|
return callback(err, result)
|
|
|
|
clearUserSessions: (user, callback=(err)->) ->
|
|
sessionSetKey = UserSessionsRedis.sessionSetKey(user)
|
|
rclient.smembers sessionSetKey, (err, sessionKeys) ->
|
|
if err
|
|
return callback(err)
|
|
if sessionKeys.length == 0
|
|
return callback(null)
|
|
actions = sessionKeys.map (k) ->
|
|
(cb) ->
|
|
rclient.del k, (err) ->
|
|
cb(err)
|
|
Async.series(
|
|
actions, (err, results) ->
|
|
rclient.srem sessionSetKey, sessionKeys, (err) ->
|
|
if err
|
|
return callback(err)
|
|
callback(null)
|
|
)
|