From 9fb4a1d540822ee4557bb2e700cd3ed9d422b44d Mon Sep 17 00:00:00 2001 From: Menci Date: Wed, 7 Nov 2018 13:21:53 +0800 Subject: [PATCH] Fix a non-admin user edit its article caused article loses is_notice --- modules/discussion.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/discussion.js b/modules/discussion.js index c700de3..bcc6d78 100644 --- a/modules/discussion.js +++ b/modules/discussion.js @@ -190,7 +190,7 @@ app.post('/article/:id/edit', async (req, res) => { article.title = req.body.title; article.content = req.body.content; article.update_time = time; - article.is_notice = res.locals.user && res.locals.user.is_admin && req.body.is_notice === 'on'; + article.is_notice = (res.locals.user && res.locals.user.is_admin ? req.body.is_notice === 'on' : article.is_notice); await article.save();