diff --git a/server/app.js b/server/app.js index efa3818..b765c55 100644 --- a/server/app.js +++ b/server/app.js @@ -24,3 +24,4 @@ MongoClient.connect('mongodb+srv://admin:qwer1234@cluster0.mj0ea.mongodb.net/mon console.log('listening on 8080'); }); }); + diff --git a/server/routes/auth.js b/server/routes/auth.js index 5d73f59..44a1414 100644 --- a/server/routes/auth.js +++ b/server/routes/auth.js @@ -13,6 +13,13 @@ module.exports = function(passport){ res.redirect('/posts') }); + router.get('/logout',isAuth,function(req,res){ + req.session.destroy(function(error){ + res.redirect('/auth/login') + + }) + }); + router.get('/signup', function(req, res){ res.render('signup.ejs'); }); @@ -56,5 +63,13 @@ router.post('/signup/id-check', function(req, res){ } } +function isAuth(req,res,next){ + if(req.user){ + next() + }else{ + res.send('로그인을 해주세요.') + } +} + return router; } diff --git a/server/routes/posts.js b/server/routes/posts.js index 9638373..4512e9c 100644 --- a/server/routes/posts.js +++ b/server/routes/posts.js @@ -65,7 +65,7 @@ router.post('/write', function (req, res) { req.app.db.collection('posts').findOne({ _id : parseInt(req.params.id) }, function(error, result){ res.render('detail.ejs', {posts : result} ) }) - }); - + }); + module.exports = router; \ No newline at end of file diff --git a/server/views/detail.ejs b/server/views/detail.ejs index e38a850..b7b7187 100644 --- a/server/views/detail.ejs +++ b/server/views/detail.ejs @@ -8,7 +8,7 @@ - Hello, world! + Happy bank -

Happy Money



+

Happy bank



Date. <%= posts.date %>

Title. <%= posts.title %> Happy Money. <%= posts.money %>won

diff --git a/server/views/navstyle.html b/server/views/navstyle.html index 88c62c3..715af37 100644 --- a/server/views/navstyle.html +++ b/server/views/navstyle.html @@ -10,6 +10,6 @@ Info