From b55869bf7465a46b812960bf9cc16eb6ad2c83b9 Mon Sep 17 00:00:00 2001 From: Guilherme Gazzo Date: Fri, 26 Jul 2024 20:30:38 -0300 Subject: [PATCH] regression: notify user properly on logout (#32920) --- apps/meteor/app/api/server/v1/users.ts | 2 +- apps/meteor/server/lib/resetUserE2EKey.ts | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/apps/meteor/app/api/server/v1/users.ts b/apps/meteor/app/api/server/v1/users.ts index 26ef2fa30ff2..7ae585b89dfa 100644 --- a/apps/meteor/app/api/server/v1/users.ts +++ b/apps/meteor/app/api/server/v1/users.ts @@ -1216,7 +1216,7 @@ API.v1.addRoute( throw new Meteor.Error('error-invalid-user-id', 'Invalid user id'); } - void notifyOnUserChange({ clientAction: 'updated', id: this.userId, diff: { 'services.resume.loginTokens': [] } }); + void notifyOnUserChange({ clientAction: 'updated', id: userId, diff: { 'services.resume.loginTokens': [] } }); return API.v1.success({ message: `User ${userId} has been logged out!`, diff --git a/apps/meteor/server/lib/resetUserE2EKey.ts b/apps/meteor/server/lib/resetUserE2EKey.ts index 3f30251dbb11..8535eee9a2cd 100644 --- a/apps/meteor/server/lib/resetUserE2EKey.ts +++ b/apps/meteor/server/lib/resetUserE2EKey.ts @@ -2,6 +2,7 @@ import { api } from '@rocket.chat/core-services'; import { Subscriptions, Users, Rooms } from '@rocket.chat/models'; import { Meteor } from 'meteor/meteor'; +import { notifyOnUserChange } from '../../app/lib/server/lib/notifyListener'; import * as Mailer from '../../app/mailer/server/api'; import { settings } from '../../app/settings/server'; import { i18n } from './i18n'; @@ -76,5 +77,7 @@ export async function resetUserE2EEncriptionKey(uid: string, notifyUser: boolean // Force the user to logout, so that the keys can be generated again await Users.unsetLoginTokens(uid); + void notifyOnUserChange({ clientAction: 'updated', id: uid, diff: { 'services.resume.loginTokens': [] } }); + return true; }