Update model.session.userId for next requests

This commit is contained in:
Tyler Renelle 2012-07-17 18:10:17 -04:00
parent f1666f2d39
commit 5bed0351af
2 changed files with 6 additions and 4 deletions

View file

@ -88,6 +88,7 @@ get('/:userId?', function(page, model, _arg) {
debuggingUsers = parseInt(userId) < 40;
if ((userId != null) && (users.get(userId) || debuggingUsers)) {
model.set('_userId', userId);
model.session.userId = userId;
}
userId = model.get('_userId');
if (!model.get("users." + userId)) {

View file

@ -48,14 +48,15 @@ debug = (obj, message) ->
console.log obj, "[debug] #{message}"
get '/:userId?', (page, model, {userId}) ->
model.subscribe "users", (err, users) ->
# Previously saved session (eg, http://localhost/{guid}) (temporary solution until authentication built)
# Previously saved session (eg, http://localhost/{guid}) (temporary solution until authentication built)
debuggingUsers = (parseInt(userId) < 40) #these are users created before guid was in use, need to convert them to guid and get rid of this
if userId? and (users.get(userId) or debuggingUsers)
model.set '_userId', userId
model.set '_userId', userId # set for this request
model.session.userId = userId # and for next requests
# Current browser session
# The session middleware will assign a _userId automatically
# Render page if a userId is already stored in session data