Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions app/lib/server/startup/userDataStream.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { MongoInternals } from 'meteor/mongo';

import { Users } from '../../../models/server';
import { Notifications } from '../../../notifications/server';
import loginServiceConfiguration from '../../../models/server/models/LoginServiceConfiguration';

let processOnChange;
// eslint-disable-next-line no-undef
Expand All @@ -10,6 +11,7 @@ const disableOplog = Package['disable-oplog'];
if (disableOplog) {
// Stores the callbacks for the disconnection reactivity bellow
const userCallbacks = new Map();
const serviceConfigCallbacks = new Set();

// Overrides the native observe changes to prevent database polling and stores the callbacks
// for the users' tokens to re-implement the reactivity based on our database listeners
Expand All @@ -32,11 +34,17 @@ if (disableOplog) {
userCallbacks.set(selector._id, cbs);
}
}

if (collectionName === 'meteor_accounts_loginServiceConfiguration') {
serviceConfigCallbacks.add(callbacks);
}

return {
stop() {
if (cbs) {
cbs.delete(callbacks);
}
serviceConfigCallbacks.delete(callbacks);
},
};
};
Expand All @@ -57,6 +65,23 @@ if (disableOplog) {
}
}
};

loginServiceConfiguration.on('change', ({ clientAction, id, data, diff }) => {
switch (clientAction) {
case 'inserted':
case 'updated':
const record = { ...data || diff };
delete record.secret;
serviceConfigCallbacks.forEach((callbacks) => {
callbacks[clientAction === 'inserted' ? 'added' : 'changed']?.(id, record);
});
break;
case 'removed':
serviceConfigCallbacks.forEach((callbacks) => {
callbacks.removed?.(id);
});
}
});
}

Users.on('change', ({ clientAction, id, data, diff }) => {
Expand Down
7 changes: 7 additions & 0 deletions app/models/server/models/LoginServiceConfiguration.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
import { ServiceConfiguration } from 'meteor/service-configuration';

import { Base } from './_Base';

export class LoginServiceConfiguration extends Base {}

export default new LoginServiceConfiguration(ServiceConfiguration.configurations, { preventSetUpdatedAt: true });