From 5bf2242147e7d6122f819de01a20a194440ef296 Mon Sep 17 00:00:00 2001 From: moepoi Date: Sun, 21 Nov 2021 09:13:58 +0700 Subject: [PATCH] Add logout --- routes/index.js | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/routes/index.js b/routes/index.js index e4d6fb7..2511bd4 100644 --- a/routes/index.js +++ b/routes/index.js @@ -81,6 +81,19 @@ router.route("/login") }); }); +router.route("/logout") +.get((req, res) => { + auth.session_converter(req.cookies.session_token).then((key) => { + if (key != null) { + res.clearCookie("session_token"); + auth.session_remove(key, req.cookies.session_token); + res.redirect("/"); + } else { + res.redirect("/login"); + } + }); +}) + router.get("/verify-mail", (req, res) => { controller.verify_mail(req.query.token).then((data) => { if (data == 200) {