mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-23 14:10:50 +00:00
27 lines
723 B
CoffeeScript
27 lines
723 B
CoffeeScript
|
Settings = require("settings-sharelatex")
|
||
|
redis = require("redis-sharelatex")
|
||
|
rclient = redis.createClient(Settings.redis.web)
|
||
|
crypto = require("crypto")
|
||
|
async = require("async")
|
||
|
|
||
|
|
||
|
module.exports =
|
||
|
|
||
|
_getEmailKey : (email)->
|
||
|
hash = crypto.createHash("md5").update(email).digest("hex")
|
||
|
return "e_sess:#{hash}"
|
||
|
|
||
|
tracksession:(sessionId, email, callback = ->)->
|
||
|
session_lookup_key = @_getEmailKey(email)
|
||
|
rclient.set session_lookup_key, sessionId, callback
|
||
|
|
||
|
invalidateSession:(email, callback = ->)->
|
||
|
session_lookup_key = @_getEmailKey(email)
|
||
|
rclient.get session_lookup_key, (err, sessionId)->
|
||
|
async.series [
|
||
|
(cb)-> rclient.del sessionId, cb
|
||
|
(cb)-> rclient.del session_lookup_key, cb
|
||
|
], callback
|
||
|
|
||
|
|