diff --git a/routes/auth.js b/routes/auth.js index 539813b..c458cbc 100644 --- a/routes/auth.js +++ b/routes/auth.js @@ -146,7 +146,7 @@ router.post('/connexion', async function (req, res) { }) return; } - req.session.user = { id: existingUser._id, nom_dutilisateur: existingUser.nom_dutilisateur}; + req.session.user = { id: existingUser._id, nom_dutilisateur: existingUser.nom_dutilisateur, nom: existingUser.nom, prenom: existingUser.prenom, email: existingUser.email}; req.session.isAuthenticated = true; req.session.save(function () { res.redirect('/'); diff --git a/routes/posts.js b/routes/posts.js index e9789bc..d3d6564 100644 --- a/routes/posts.js +++ b/routes/posts.js @@ -85,4 +85,12 @@ router.post('/submitResolution/:postId', upload.single('image'), async function return res.redirect('/hotLine') }) +router.post('/accepter/:id', async function (req, res) { + const postId = req.params.id; + const winner = req.body.utilisateur; + await db.getDb().collection('post').updateOne({_id: postId}, {isFinish: true}); + await db.getDb().collection('res').updateOne({_id: postId}, {winner: winner}); + res.redirect('/admin') +}) + module.exports = router; \ No newline at end of file diff --git a/views/adminPage.ejs b/views/adminPage.ejs index 2ad0bac..cba6ec5 100644 --- a/views/adminPage.ejs +++ b/views/adminPage.ejs @@ -67,36 +67,62 @@
- <%= post.commentairePost %> -
-- Récompense : <%= post.recompense %> -
-- statue : Accepté -
-- Déscription : <%= post.commentaire %> -
-- Récompense : <%= post.recompense %> -
-- statue : en attente -
- -+ <%= post.commentairePost %> +
++ Récompense : <%= post.recompense %> +
++ statue : Accepté +
++ Déscription : <%= post.commentaire %> +
++ Récompense : <%= post.recompense %> +
++ statue : en attente +
+ ++ <%= res.description %> +
+