feat: add user last seen field

This commit is contained in:
Sonny
2024-10-07 02:07:39 +02:00
parent 24cea2b0b2
commit c8fb5af44d
11 changed files with 103 additions and 36 deletions

View File

@@ -0,0 +1,16 @@
import type { HttpContext } from '@adonisjs/core/http';
import type { NextFn } from '@adonisjs/core/types/http';
import { DateTime } from 'luxon';
export default class UpdateUserLastSeenMiddleware {
async handle(ctx: HttpContext, next: NextFn) {
const user = ctx.auth.user;
if (user) {
user.lastSeenAt = DateTime.local();
await user.save();
}
const output = await next();
return output;
}
}