2019-11-23 17:40:51 +01:00
|
|
|
import Pages from '../../data/Pages';
|
2018-12-08 19:21:48 +01:00
|
|
|
const express = require('express');
|
|
|
|
const router = express.Router();
|
2019-11-16 20:05:48 +01:00
|
|
|
const settings = require('../../../config/site-settings.json');
|
2019-11-20 02:17:39 +01:00
|
|
|
|
2018-10-31 17:00:31 +01:00
|
|
|
//--------------------------
|
|
|
|
// Index
|
|
|
|
//--------------------------
|
2019-11-16 20:05:48 +01:00
|
|
|
router.get('/', function(req, res) {
|
2019-11-20 02:17:39 +01:00
|
|
|
let pages = new Pages();
|
2019-11-20 07:01:31 +01:00
|
|
|
pages.grab().then(result => {
|
2019-11-20 02:17:39 +01:00
|
|
|
let pageData = [];
|
|
|
|
if (req.session.user) {
|
|
|
|
pageData = { title: settings.title, status: true, pages: result };
|
|
|
|
} else {
|
|
|
|
pageData = { title: settings.title, status: false, pages: result };
|
|
|
|
}
|
2019-11-16 20:05:48 +01:00
|
|
|
|
2019-11-22 07:36:18 +01:00
|
|
|
res.render('index', pageData);
|
2019-11-16 20:05:48 +01:00
|
|
|
});
|
|
|
|
});
|
2019-10-12 01:10:55 +02:00
|
|
|
|
2018-10-31 17:00:31 +01:00
|
|
|
//--------------------------
|
2018-12-08 19:21:48 +01:00
|
|
|
// Logout
|
2018-10-31 17:00:31 +01:00
|
|
|
//--------------------------
|
2019-02-27 17:17:51 +01:00
|
|
|
router.post('/logout', function(req, res) {
|
|
|
|
req.logout();
|
|
|
|
return res.json({
|
|
|
|
message: 'LOGGED OUT'
|
|
|
|
});
|
2018-10-31 17:00:31 +01:00
|
|
|
});
|
2018-12-08 19:21:48 +01:00
|
|
|
module.exports = router;
|