2023-11-01 02:01:18 +00:00
|
|
|
const express = require('express');
|
|
|
|
|
|
|
|
const bcrypt = require('bcryptjs');
|
|
|
|
|
|
|
|
const db = require('../data/database');
|
|
|
|
const Post = require('../models/post')
|
|
|
|
|
|
|
|
const router = express.Router();
|
|
|
|
|
|
|
|
router.get('/', function (req, res) {
|
|
|
|
res.render('index');
|
|
|
|
});
|
|
|
|
|
|
|
|
router.get('/profile', function(req, res) {
|
|
|
|
if (!req.session.isAuthenticated) {
|
|
|
|
return res.status(401).render('401');
|
|
|
|
}
|
|
|
|
res.render('profile');
|
|
|
|
});
|
|
|
|
|
|
|
|
router.get('/admin', async function (req, res) {
|
|
|
|
if (!req.session.isAuthenticated) {
|
|
|
|
return res.status(401).render('401');
|
|
|
|
}
|
|
|
|
const user = await db.getDb().collection('users').findOne({_id: req.session.user.id})
|
|
|
|
if (!user || !user.isAdmin) {
|
|
|
|
return res.status(403).render('403');
|
|
|
|
}
|
|
|
|
|
|
|
|
const users = await db.getDb().collection('users').find().toArray();
|
2023-11-01 23:03:46 +00:00
|
|
|
const postData = await db.getDb().collection('posts').find().toArray();
|
|
|
|
const resData = await db.getDb().collection('res').find().toArray();
|
2023-11-06 00:46:03 +00:00
|
|
|
const commandeData = await db.getDb().collection('commandes').find().toArray();
|
|
|
|
res.render('adminPage', {users: users, postData: postData, resData:resData, commandeData: commandeData});
|
2023-11-01 02:01:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
|
|
router.get('/contact', function (req, res) {
|
2023-11-03 23:48:04 +00:00
|
|
|
res.render('futur')
|
2023-11-01 02:01:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
router.get('/sports', function (req,res) {
|
2023-11-03 23:48:04 +00:00
|
|
|
res.render('futur')
|
2023-11-01 02:01:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
router.get('/services', function (req,res) {
|
2023-11-03 23:48:04 +00:00
|
|
|
res.render('futur')
|
2023-11-01 02:01:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
router.get('/team', function (req,res) {
|
2023-11-03 23:48:04 +00:00
|
|
|
res.render('futur')
|
2023-11-01 02:01:18 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
router.get('/a-propos', function (req,res) {
|
2023-11-03 23:48:04 +00:00
|
|
|
res.render('futur')
|
2023-11-01 02:01:18 +00:00
|
|
|
})
|
|
|
|
|
2023-11-05 23:12:49 +00:00
|
|
|
router.get('/evenement', function (req,res) {
|
|
|
|
res.render('futur')
|
|
|
|
})
|
2023-11-01 02:01:18 +00:00
|
|
|
|
|
|
|
module.exports = router;
|