settingsv1
This commit is contained in:
parent
e46bbf1195
commit
c0413705a8
@ -1,3 +1,5 @@
|
|||||||
|
import sql from "../../inc/sql.mjs";
|
||||||
|
|
||||||
const auth = async (req, res, next) => {
|
const auth = async (req, res, next) => {
|
||||||
if(!req.session)
|
if(!req.session)
|
||||||
return res.redirect("/login");
|
return res.redirect("/login");
|
||||||
@ -6,8 +8,17 @@ const auth = async (req, res, next) => {
|
|||||||
|
|
||||||
export default (router, tpl) => {
|
export default (router, tpl) => {
|
||||||
router.group(/^\/settings/, group => {
|
router.group(/^\/settings/, group => {
|
||||||
group.get(/$/, auth, (req, res) => {
|
group.get(/$/, auth, async (req, res) => {
|
||||||
res.end("settings lol");
|
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)
|
||||||
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
43
views/settings.html
Normal file
43
views/settings.html
Normal file
@ -0,0 +1,43 @@
|
|||||||
|
@include(main/header)
|
||||||
|
<h1>Settings</h1>
|
||||||
|
<h2>Account</h2>
|
||||||
|
<table class="table">
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<td>UserID</td>
|
||||||
|
<td>{{ session.id }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>level</td>
|
||||||
|
<td>{{ session.level }}</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>username</td>
|
||||||
|
<td>{!! session.user !!}</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<h2>Sessions</h2>
|
||||||
|
<table class="table">
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th>id</th>
|
||||||
|
<th>browser</th>
|
||||||
|
<th>created_at</th>
|
||||||
|
<th>last_used</th>
|
||||||
|
<th>last_action</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
@each(sessions as sess)
|
||||||
|
<tr>
|
||||||
|
<td>{{ sess.id }}</td>
|
||||||
|
<td>{{ sess.browser }}</td>
|
||||||
|
<td>{{ new Date(sess.created_at * 1e3).toLocaleString("de-DE") }}</td>
|
||||||
|
<td>{{ new Date(sess.last_used * 1e3).toLocaleString("de-DE") }}</td>
|
||||||
|
<td><a href="{{ sess.last_action }}" target="_blank">{{ sess.last_action }}</a></td>
|
||||||
|
</tr>
|
||||||
|
@endeach
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
@include(main/footer)
|
Loading…
Reference in New Issue
Block a user