fix(api): return the terminated count from terminate sessions (#2539)

This commit is contained in:
Hampus authored and GitHub committed 2026-09-06 18:38:46 +02:00
1 parent 2f159852a7
commit d9f983b08e
4 files changed
+14 -27

No files matched your search

@@ -315,7 +315,7 @@ export class AdminUserSecurityService {
if (!user) {
throw new UnknownUserError();
}
await AuthSession.terminateAllUserSessions(this.deps.apiContext, userId);
const terminatedCount = await AuthSession.terminateAllUserSessions(this.deps.apiContext, userId);
await auditService.createAuditLog({
adminUserId,
targetType: 'user',
@@ -324,6 +324,7 @@ export class AdminUserSecurityService {
auditLogReason,
metadata: new Map(),
});
return {terminated_count: terminatedCount};
}
async setUserAcls(
+3 -2
View File
@@ -178,18 +178,19 @@ export async function logoutAuthSessions(
});
}
export async function terminateAllUserSessions(ctx: ApiContext, userId: UserID): Promise<void> {
export async function terminateAllUserSessions(ctx: ApiContext, userId: UserID): Promise<number> {
const {users, gateway} = ctx.services;
const authSessions = await users.listAuthSessions(userId);
await users.deleteAllPushSubscriptions(userId);
await gateway.invalidatePushSubscriptions({userId});
if (authSessions.length === 0) return;
if (authSessions.length === 0) return 0;
const hashes = authSessions.map((s) => s.sessionIdHash);
await users.deleteAuthSessions(userId, hashes);
await gateway.terminateSession({
userId,
sessionIdHashes: authSessions.map((s) => Buffer.from(s.sessionIdHash).toString('base64url')),
});
return authSessions.length;
}
export async function replaceCurrentAuthSession(