keep me signed in

This commit is contained in:
Flummi 2022-03-23 05:58:48 +01:00
parent 1262b12ee4
commit 33d60446f1
3 changed files with 10 additions and 1 deletions

View File

@ -38,8 +38,14 @@ export default (router, tpl) => {
browser: req.headers["user-agent"],
created_at: stamp,
last_used: stamp,
last_action: "/login"
last_action: "/login",
kmsi: req.post.kmsi === 'on' ? 1 : 0
});
await sql("user_sessions") // delete unused sessions
.where('last_action', '<=', (Date.now() - 6048e5))
.andWhere('kmsi', 0)
.del();
return res.writeHead(301, {
"Cache-Control": "no-cache, public",

View File

@ -11,6 +11,7 @@
<p><a href="/"><img src="/s/img/f0ck_small.png" /></a></p>
<input type="text" name="username" placeholder="username" autocomplete="off" required />
<input type="password" name="password" placeholder="password" autocomplete="off" required />
<p><input type="checkbox" id="kmsi" name="kmsi" /> <label for="kmsi">stay signed in</label></p>
<button type="submit">Login</button>
</form>
</body>

View File

@ -26,6 +26,7 @@
<table class="table">
<thead>
<tr>
<th></th>
<th>id</th>
<th>created_at</th>
<th>last_used</th>
@ -36,6 +37,7 @@
<tbody>
@each(sessions as sess)
<tr@if(sess.id === session.sess_id) style="background-color: rgb(0, 89, 0)"@endif>
<td>{{ sess.kmsi ? '&#9875;' : '' }}</td>
<td tooltip="{{ sess.browser }}" flow="right">{{ sess.id }}</td>
<td>{{ new Date(sess.created_at * 1e3).toLocaleString("de-DE") }}</td>
<td>{{ new Date(sess.last_used * 1e3).toLocaleString("de-DE") }}</td>