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)