diff --git a/routes/chat.js b/routes/chat.js index 9d8e438d..a0a82155 100644 --- a/routes/chat.js +++ b/routes/chat.js @@ -20,7 +20,7 @@ router.use(bodyParser.urlencoded({ extended: false })) /* GET home page. */ -router.get('/' , function(req, res, next) { +router.get('/', checkAuthentication, function(req, res, next) { chatData.find({users: {$elemMatch : { @@ -72,5 +72,16 @@ router.post('/messages',async (req, res) => { }) +//authenticate a user is logged in +function checkAuthentication(req,res,next){ + if(req.isAuthenticated()){ + //req.isAuthenticated() will return true if user is logged in + next(); + } else{ + req.session.authorigin = 'chat'; + res.redirect('/auth/google/callback') + } +} + module.exports = router; diff --git a/views/chat.hbs b/views/chat.hbs index d7b13557..0d2602c6 100644 --- a/views/chat.hbs +++ b/views/chat.hbs @@ -51,11 +51,14 @@ img{ max-width:100%;} width: 88%; } -.chat_people{ overflow:hidden; clear:both;} +.chat_people{ + overflow:hidden; + clear:both; + padding: 20px 10px; +} .chat_list { border-bottom: 1px solid #c4c4c4; margin: 0; - padding: 18px 16px 10px; } .inbox_chat { height: 550px; overflow-y: scroll;} @@ -145,17 +148,19 @@ img{ max-width:100%;}
Item: {{this.selectedPostTitle}}
+ {{#ifEquals this.selectedPersonSelling ../currentSession.passport.user._json.email}} +