fipamo/brain/routes/dash/index.js

33 lines
787 B
JavaScript
Raw Normal View History

2019-11-23 09:03:30 +01:00
import Pages from '../../content/Pages';
const express = require('express');
const router = express.Router();
const settings = require('../../../config/site-settings.json');
2018-10-31 17:00:31 +01:00
//--------------------------
// Index
//--------------------------
router.get('/', function(req, res) {
let pages = new Pages();
2019-11-20 07:01:31 +01:00
pages.grab().then(result => {
let pageData = [];
if (req.session.user) {
pageData = { title: settings.title, status: true, pages: result };
} else {
pageData = { title: settings.title, status: false, pages: result };
}
res.render('index', pageData);
});
});
2018-10-31 17:00:31 +01:00
//--------------------------
// Logout
2018-10-31 17:00:31 +01:00
//--------------------------
router.post('/logout', function(req, res) {
req.logout();
return res.json({
message: 'LOGGED OUT'
});
2018-10-31 17:00:31 +01:00
});
module.exports = router;