2017-10-11 01:00:08 +02:00
|
|
|
const logger = require('winston');
|
|
|
|
|
|
|
|
module.exports = {
|
|
|
|
populateLocalsDotUser (req, res, next) {
|
|
|
|
if (req.user) {
|
2017-12-01 02:24:48 +01:00
|
|
|
logger.debug('populating res.locals.user');
|
2017-10-11 01:00:08 +02:00
|
|
|
res.locals.user = {
|
|
|
|
id : req.user.id,
|
|
|
|
userName : req.user.userName,
|
|
|
|
channelName : req.user.channelName,
|
|
|
|
channelClaimId: req.user.channelClaimId,
|
|
|
|
shortChannelId: req.user.shortChannelId,
|
|
|
|
};
|
|
|
|
}
|
|
|
|
next();
|
|
|
|
},
|
2017-12-01 02:24:48 +01:00
|
|
|
serializeSpeechUser (user, done) { // returns user data to be serialized into session
|
|
|
|
logger.debug('serializing user');
|
|
|
|
done(null, user);
|
2017-10-11 01:00:08 +02:00
|
|
|
},
|
2017-12-01 02:24:48 +01:00
|
|
|
deserializeSpeechUser (user, done) { // deserializes session and populates additional info to req.user
|
|
|
|
logger.debug('deserializing user');
|
|
|
|
done(null, user);
|
2017-10-11 01:00:08 +02:00
|
|
|
},
|
|
|
|
};
|