diff options
author | Julien Dessaux | 2022-10-31 22:40:42 +0100 |
---|---|---|
committer | Julien Dessaux | 2022-10-31 22:40:42 +0100 |
commit | b91bb0a133aa3d0400beb359fed4e641c888ab26 (patch) | |
tree | 0b703fab300ab39ffd39708b193bcfa09e89f6f5 /routes/logout.js | |
parent | Fixed middleware action without return (diff) | |
download | jeux-de-mots-b91bb0a133aa3d0400beb359fed4e641c888ab26.tar.gz jeux-de-mots-b91bb0a133aa3d0400beb359fed4e641c888ab26.tar.bz2 jeux-de-mots-b91bb0a133aa3d0400beb359fed4e641c888ab26.zip |
Added logout route, and a way to display the logout menu item on relevant pages
Diffstat (limited to '')
-rw-r--r-- | routes/logout.js | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/routes/logout.js b/routes/logout.js new file mode 100644 index 0000000..a31d9fe --- /dev/null +++ b/routes/logout.js @@ -0,0 +1,15 @@ +import express from "express"; + +import session from "../middlewares/sessions.js"; + +const router = express.Router(); +router.use(session); + +router.get("/", (req, res) => { + if (req.session.user !== undefined) { + req.session.destroy(); + } + return res.redirect(302, "/"); +}); + +export default router; |