Skip to content

Commit

Permalink
fix user.forceLogout for microservices
Browse files Browse the repository at this point in the history
  • Loading branch information
ggazzo committed Apr 22, 2024
1 parent 7eca905 commit 4e8f579
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 2 deletions.
5 changes: 3 additions & 2 deletions apps/meteor/server/lib/resetUserE2EKey.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { api } from '@rocket.chat/core-services';
import { Subscriptions, Users } from '@rocket.chat/models';
import { Meteor } from 'meteor/meteor';

import * as Mailer from '../../app/mailer/server/api';
import { Notifications } from '../../app/notifications/server';
import { settings } from '../../app/settings/server';
import { i18n } from './i18n';
import { isUserIdFederated } from './isUserIdFederated';
Expand Down Expand Up @@ -66,7 +66,8 @@ export async function resetUserE2EEncriptionKey(uid: string, notifyUser: boolean
}

// force logout the live sessions
Notifications.notifyUser(uid, 'force_logout');

await api.broadcast('user.forceLogout', uid);

await Users.resetE2EKey(uid);
await Subscriptions.resetUserE2EKey(uid);
Expand Down
4 changes: 4 additions & 0 deletions apps/meteor/server/modules/listeners/listeners.module.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,10 @@ export class ListenersModule {
});
});

service.onEvent('user.forceLogout', (uid) => {
notifications.notifyUserInThisInstance(uid, 'force_logout');
});

service.onEvent('notify.ephemeralMessage', (uid, rid, message) => {
if (!isMessageParserDisabled && message.msg) {
const customDomains = settings.get<string>('Message_CustomDomain_AutoLink')
Expand Down
1 change: 1 addition & 0 deletions packages/core-services/src/events/Events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,6 +130,7 @@ export type EventSignatures = {
},
): void;
'user.deleteCustomStatus'(userStatus: Omit<ICustomUserStatus, '_updatedAt'>): void;
'user.forceLogout': (uid: string) => void;
'user.nameChanged'(user: Pick<IUser, '_id' | 'name' | 'username'>): void;
'user.realNameChanged'(user: Partial<IUser>): void;
'user.roleUpdate'(update: {
Expand Down

0 comments on commit 4e8f579

Please sign in to comment.