Missing returns and page check
parent
cfb617a93a
commit
3e065c2610
|
@ -276,6 +276,7 @@ router.post('/admin/settings/page', restrict, checkAccess, async (req, res) => {
|
||||||
const page = await db.pages.findOne({ _id: common.getId(req.body.pageId) });
|
const page = await db.pages.findOne({ _id: common.getId(req.body.pageId) });
|
||||||
if(!page){
|
if(!page){
|
||||||
res.status(400).json({ message: 'Page not found' });
|
res.status(400).json({ message: 'Page not found' });
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
|
@ -299,6 +300,13 @@ router.post('/admin/settings/page', restrict, checkAccess, async (req, res) => {
|
||||||
// delete page
|
// delete page
|
||||||
router.post('/admin/settings/page/delete', restrict, checkAccess, async (req, res) => {
|
router.post('/admin/settings/page/delete', restrict, checkAccess, async (req, res) => {
|
||||||
const db = req.app.db;
|
const db = req.app.db;
|
||||||
|
|
||||||
|
const page = await db.pages.findOne({ _id: common.getId(req.body.pageId) });
|
||||||
|
if(!page){
|
||||||
|
res.status(400).json({ message: 'Page not found' });
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
try{
|
try{
|
||||||
await db.pages.deleteOne({ _id: common.getId(req.body.pageId) }, {});
|
await db.pages.deleteOne({ _id: common.getId(req.body.pageId) }, {});
|
||||||
res.status(200).json({ message: 'Page successfully deleted' });
|
res.status(200).json({ message: 'Page successfully deleted' });
|
||||||
|
|
Loading…
Reference in New Issue