summaryrefslogtreecommitdiff
path: root/routes/logout.js
diff options
context:
space:
mode:
Diffstat (limited to 'routes/logout.js')
-rw-r--r--routes/logout.js15
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;