settingsv1

This commit is contained in:
Flummi
2021-12-24 11:16:29 +01:00
parent e46bbf1195
commit c0413705a8
2 changed files with 56 additions and 2 deletions

View File

@ -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)
});
});
});