From c0413705a8e3cebabeda8fcf45bf05d9ce6345a1 Mon Sep 17 00:00:00 2001 From: Flummi Date: Fri, 24 Dec 2021 11:16:29 +0100 Subject: [PATCH] settingsv1 --- src/inc/routes/settings.mjs | 15 +++++++++++-- views/settings.html | 43 +++++++++++++++++++++++++++++++++++++ 2 files changed, 56 insertions(+), 2 deletions(-) create mode 100644 views/settings.html diff --git a/src/inc/routes/settings.mjs b/src/inc/routes/settings.mjs index b4f771e..644075c 100644 --- a/src/inc/routes/settings.mjs +++ b/src/inc/routes/settings.mjs @@ -1,3 +1,5 @@ +import sql from "../../inc/sql.mjs"; + const auth = async (req, res, next) => { if(!req.session) return res.redirect("/login"); @@ -6,8 +8,17 @@ const auth = async (req, res, next) => { export default (router, tpl) => { router.group(/^\/settings/, group => { - group.get(/$/, auth, (req, res) => { - res.end("settings lol"); + group.get(/$/, auth, async (req, res) => { + const sessions = await sql("user_sessions") + .where("user_id", req.session.id) + .orderBy("last_used", "desc"); + + res.reply({ + body: tpl.render('settings', { + tmp: null, + sessions + }, req) + }); }); }); diff --git a/views/settings.html b/views/settings.html new file mode 100644 index 0000000..6d0ee42 --- /dev/null +++ b/views/settings.html @@ -0,0 +1,43 @@ +@include(main/header) +

Settings

+

Account

+ + + + + + + + + + + + + + + +
UserID{{ session.id }}
level{{ session.level }}
username{!! session.user !!}
+

Sessions

+ + + + + + + + + + + + @each(sessions as sess) + + + + + + + + @endeach + +
idbrowsercreated_atlast_usedlast_action
{{ sess.id }}{{ sess.browser }}{{ new Date(sess.created_at * 1e3).toLocaleString("de-DE") }}{{ new Date(sess.last_used * 1e3).toLocaleString("de-DE") }}{{ sess.last_action }}
+@include(main/footer)