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,9 +38,15 @@ export default (router, tpl) => {
browser: req.headers["user-agent"], browser: req.headers["user-agent"],
created_at: stamp, created_at: stamp,
last_used: 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, { return res.writeHead(301, {
"Cache-Control": "no-cache, public", "Cache-Control": "no-cache, public",
"Set-Cookie": `session=${session}; Path=/; Expires=Fri, 31 Dec 9999 23:59:59 GMT`, "Set-Cookie": `session=${session}; Path=/; Expires=Fri, 31 Dec 9999 23:59:59 GMT`,

View File

@ -11,6 +11,7 @@
<p><a href="/"><img src="/s/img/f0ck_small.png" /></a></p> <p><a href="/"><img src="/s/img/f0ck_small.png" /></a></p>
<input type="text" name="username" placeholder="username" autocomplete="off" required /> <input type="text" name="username" placeholder="username" autocomplete="off" required />
<input type="password" name="password" placeholder="password" 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> <button type="submit">Login</button>
</form> </form>
</body> </body>

View File

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