diff --git a/lib/user.js b/lib/user.js index 5ff29264..28cad443 100644 --- a/lib/user.js +++ b/lib/user.js @@ -721,6 +721,7 @@ module.exports = function (config, userDB, couchAuthDB, mailer, emitter) { this.refreshSession = function (key) { var newSession; + var user; return session.fetchToken(key) .then(function(oldToken) { newSession = oldToken; @@ -737,6 +738,7 @@ module.exports = function (config, userDB, couchAuthDB, mailer, emitter) { return self.logoutUserSessions(userDoc, 'expired'); }) .then(function(finalUser) { + user = finalUser; return userDB.put(finalUser); }) .then(function() { @@ -747,6 +749,10 @@ module.exports = function (config, userDB, couchAuthDB, mailer, emitter) { delete newSession._id; delete newSession.salt; delete newSession.derived_key; + newSession.roles = user.roles; + if(user.profile) { + newSession.profile = user.profile; + } emitter.emit('refresh', newSession); return BPromise.resolve(newSession); });