Met a jour lastConnectionAt sur /api/me
This commit is contained in:
Vendored
+11
-1
@@ -626,7 +626,17 @@ function registerAuthApiRoutes(options) {
|
|||||||
return res.status(200).json({ ok: true });
|
return res.status(200).json({ ok: true });
|
||||||
});
|
});
|
||||||
options.app.get(mePath, options.requireSession, async (req, res) => {
|
options.app.get(mePath, options.requireSession, async (req, res) => {
|
||||||
res.json({ user: req.authUser });
|
const authUser = req.authUser;
|
||||||
|
if (typeof authUser?.id === "string") {
|
||||||
|
try {
|
||||||
|
await options.prisma.user.update({
|
||||||
|
where: { id: authUser.id },
|
||||||
|
data: { lastConnectionAt: /* @__PURE__ */ new Date() }
|
||||||
|
});
|
||||||
|
} catch {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
res.json({ user: authUser });
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
export {
|
export {
|
||||||
|
|||||||
Vendored
+1
-1
File diff suppressed because one or more lines are too long
+14
-1
@@ -478,6 +478,19 @@ export function registerAuthApiRoutes(options: RegisterAuthApiRoutesOptions): vo
|
|||||||
});
|
});
|
||||||
|
|
||||||
options.app.get(mePath, options.requireSession, async (req, res) => {
|
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