Met a jour lastConnectionAt sur /api/me
This commit is contained in:
+14
-1
@@ -478,6 +478,19 @@ export function registerAuthApiRoutes(options: RegisterAuthApiRoutesOptions): vo
|
||||
});
|
||||
|
||||
options.app.get(mePath, options.requireSession, async (req, res) => {
|
||||
res.json({ user: (req as { authUser?: unknown }).authUser });
|
||||
const authUser = (req as { authUser?: { id?: unknown } }).authUser;
|
||||
|
||||
if (typeof authUser?.id === "string") {
|
||||
try {
|
||||
await options.prisma.user.update({
|
||||
where: { id: authUser.id },
|
||||
data: { lastConnectionAt: new Date() }
|
||||
});
|
||||
} catch {
|
||||
// Ignore when the consumer schema does not expose lastConnectionAt.
|
||||
}
|
||||
}
|
||||
|
||||
res.json({ user: authUser });
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user