mirror of
https://github.com/Sonny93/my-links.git
synced 2025-12-08 14:43:24 +00:00
17 lines
411 B
TypeScript
17 lines
411 B
TypeScript
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;
|
|
}
|
|
}
|