mirror of
https://github.com/overleaf/overleaf.git
synced 2024-11-07 20:31:06 -05:00
save the session key string, rather than just the id
This commit is contained in:
parent
db213c0621
commit
03fedafaf5
1 changed files with 8 additions and 3 deletions
|
@ -6,13 +6,17 @@ logger = require("logger-sharelatex")
|
|||
module.exports = UserSessionsManager =
|
||||
|
||||
_sessionSetKey: (user) ->
|
||||
console.log ">>", user
|
||||
return "UserSessions:#{user._id}"
|
||||
|
||||
# mimic the key used by the express sessions
|
||||
_sessionKey: (sessionId) ->
|
||||
return "sess:#{sessionId}"
|
||||
|
||||
onLogin: (user, sessionId, callback=(err)-> ) ->
|
||||
logger.log {user_id: user._id, sessionId}, "onLogin handler"
|
||||
sessionSetKey = UserSessionsManager._sessionSetKey(user)
|
||||
rclient.sadd sessionSetKey, sessionId, (err, response) ->
|
||||
value = UserSessionsManager._sessionKey sessionId
|
||||
rclient.sadd sessionSetKey, value, (err, response) ->
|
||||
if err
|
||||
logger.err {err, user_id: user._id, sessionId}, "error while adding session key to UserSessions set"
|
||||
return callback(err)
|
||||
|
@ -24,7 +28,8 @@ module.exports = UserSessionsManager =
|
|||
logger.log {sessionId}, "no user, for some reason"
|
||||
return callback()
|
||||
sessionSetKey = UserSessionsManager._sessionSetKey(user)
|
||||
rclient.srem sessionSetKey, sessionId, (err, response) ->
|
||||
value = UserSessionsManager._sessionKey sessionId
|
||||
rclient.srem sessionSetKey, value, (err, response) ->
|
||||
if err
|
||||
logger.err {err, user_id: user._id, sessionId}, "error while removing session key from UserSessions set"
|
||||
return callback(err)
|
||||
|
|
Loading…
Reference in a new issue