robin*

해시 기반 작성자 db에 추가

1 const app = require('../server'); 1 const app = require('../server');
2 const db = require('../db'); 2 const db = require('../db');
3 +const hash = require('../hash');
3 4
4 app.get('/', async(req, res) => { 5 app.get('/', async(req, res) => {
5 res.render('boardlist', {boards: await db.get('board').find()}); 6 res.render('boardlist', {boards: await db.get('board').find()});
...@@ -23,5 +24,6 @@ app.post('/board/:bid', async(req, res) => { ...@@ -23,5 +24,6 @@ app.post('/board/:bid', async(req, res) => {
23 res.status(404).send('그런 판은 우리에게 있을 수 없어.'); 24 res.status(404).send('그런 판은 우리에게 있을 수 없어.');
24 } 25 }
25 let thread = await db.get('thread').insert({board: board._id, title: req.body.title, content: req.body.content, lastUpdated: Date.now(), count: 1}); 26 let thread = await db.get('thread').insert({board: board._id, title: req.body.title, content: req.body.content, lastUpdated: Date.now(), count: 1});
27 + await db.get('thread').update(thread._id, {$set: {writer: hash(thread._id, req.ip)}});
26 res.redirect('/thread/' + thread._id); 28 res.redirect('/thread/' + thread._id);
27 }); 29 });
......