fipamo/brain/routes/back/dash_nav.js

43 lines
1.1 KiB
JavaScript

const express = require('express');
const router = express.Router();
const Models = require('../../models');
const fs = require("fs-extra");
//--------------------------
// SETTINGS
//--------------------------
router.get('/', function(req, res)
{
if (req.session.user)
{
Models.User.findById(req.session.user.id).then((user) =>
{
let pages = [];
Models.FreshPost.findAll(
{
order: [
['id', 'DESC']
]
}).then(posts =>
{
for (let index = 0; index < posts.length; index++)
{
let item = posts[index].post;
if(item.page == true || item.page == "true") pages.push(posts[index]);
}
}).catch(err =>
{
console.log("ERROR", err)
})
res.render('dash/navigation',
{
pages: pages,
title: 'Dashboard | Global Nav'
});
})
}
else
{
res.redirect('/@/dashboard');
}
});
module.exports = router;