fix(sessions): close only the sockets of the session that ended

A ws token now carries the session it was minted under and the socket keeps it, so signing out on one device no longer drops the live socket of every other device. Ending all sessions still closes every socket of the account.
This commit is contained in:
Maurice
2026-11-28 00:33:42 +01:00
parent b5350287a4
commit 96d8b5c664
13 changed files with 118 additions and 37 deletions
+2 -2
View File
@@ -368,14 +368,14 @@ export class AuthController {
@Post('ws-token')
@HttpCode(200)
async wsToken(@CurrentUser() user: User) {
async wsToken(@CurrentUser() user: User, @Req() req: Request) {
// Own bucket, not 'login': a client that reconnects its socket in a loop
// must not be able to lock itself out of signing in. The ceiling is far
// above any real client, which mints one token per socket connect, but it
// stops a single account from filling the process-wide ephemeral store and
// 503-ing every other user's ws and download tokens.
await this.limitUser('ws_token', user.id, 120);
const result = await this.tokens.createWsToken(user.id);
const result = await this.tokens.createWsToken(user.id, currentSessionId(req));
return { token: result.token };
}